Voice React Native SDK: Reference Components
The Twilio Voice React Native Reference Components are reference implementations that show how to build common Twilio Voice use cases with the Voice React Native SDK. They ship as a single Expo app whose routes each lead to a different reference component. Every component includes both client-side code (Expo screens, React hooks, and components) and the server-side code (a Node.js backend) that supports it, so you can see an integrated frontend and backend implementation for each use case. Use the components as a starting point for your own app or as a reference while you build.
Before proceeding, review how the React Native SDK works to familiarize yourself with the core concepts.
To download the project, see twilio/twilio-voice-react-native-reference-components on GitHub.
The available reference component shows you how to create an AI conversation in a React Native/Expo application. You place an outbound call to an AI voice agent, powered by Conversation Relay and OpenAI.
- Node.js 24 or later
- A Twilio account
- An OpenAI API key (required by the AI Conversation component)
- An HTTPS tunnel to your local server, such as ngrok
- For the client: Xcode (iOS) or Android Studio (Android)
Warning
Expo Go is not supported. The Twilio Voice React Native SDK includes native code, so you must use a development build.
- Clone the Twilio Voice React Native Reference Components GitHub repository and install dependencies.
1git clone https://github.com/twilio/twilio-voice-react-native-reference-components.git2cd twilio-voice-react-native-reference-components3npm install
- In the Twilio Console, gather the credentials the components need:
- Your Account SID and Auth Token.
- An API Key SID and Secret (Account > API keys and tokens).
- A TwiML App (Voice > TwiML > TwiML Apps). Leave the Voice Request URL blank for now; you set it per component in Run a component.
- Create your configuration files from the provided examples and fill in the values.
1cp secrets.example.env secrets.env2cp url.example.env url.env
Add the credentials from the previous step to secrets.env, including your OpenAI API key.
- Provide a
google-services.jsonfile in the root of the project, adjacent topackage.json. The Twilio Voice React Native SDK requires this file for the Android prebuild step. You generate it from a Firebase project. - Start an HTTPS tunnel to your local server in a separate terminal, and note the forwarding host that it prints.
ngrok http 3030
- In
url.env, setEXPO_PUBLIC_REFERENCE_COMPONENTS_DEV_SERVER_HOSTto your tunnel host without the protocol (nohttps://).
EXPO_PUBLIC_REFERENCE_COMPONENTS_DEV_SERVER_HOST=<YOUR-TUNNEL-HOST>.ngrok.app
- Start the server.
npm run server
- Create the development build, then run it on a device or simulator.
npm run expo:prebuild
- Android: open the
android/folder in Android Studio to build and run the app. - iOS: open
ios/twiliovoicereactnativereferencecomponents.xcworkspacein Xcode to build and run the app.
- In the Twilio Console, open your TwiML App and set the Voice Request URL to the AI Conversation endpoint, using your tunnel host from setup:
- Voice Request URL:
https://<YOUR-TUNNEL-HOST>.ngrok.app/ai-conversation/twiml - Method:
POST
- Voice Request URL:
- Open the app and navigate to AI Conversation.
- Tap Connect to an Agent. You should hear the welcome greeting and then be able to ask the assistant anything.