Overview
@navai/voice-mobile provides a complete mobile stack for building voice-enabled React Native applications with Navai. It handles WebRTC transport, client secret retrieval, function loading, route-aware navigation, and React hook lifecycle management.
Prerequisites
Node.js Version
- Node.js 18.x or later recommended
Peer Dependencies
You must have the following packages installed in your React Native project:- react:
>=18 - react-native:
>=0.72 - react-native-webrtc:
>=124
Installation
Install Peer Dependencies
If you don’t already have the required packages:React Native WebRTC Setup
After installingreact-native-webrtc, you need to complete platform-specific setup:
iOS Setup
ios/YourApp/Info.plist:
Android Setup
Add permissions toandroid/app/src/main/AndroidManifest.xml:
Post-Install Auto-Setup
After installation, the package automatically runs a postinstall script that adds missing scripts to yourpackage.json. This includes:
generate:ai-modules→ Runsnavai-generate-mobile-loaderspredev→ Runsnpm run generate:ai-modulespreandroid→ Runsnpm run generate:ai-modulespreios→ Runsnpm run generate:ai-modulespretypecheck→ Runsnpm run generate:ai-modules
Disable Auto-Setup
To skip the auto-setup, set an environment variable before installation:Manual Setup
If you skipped auto-setup, you can run it manually:Environment Variables
For React Native with Expo, add toapp.config.js:
.env file:
CLI Tools
The package includes the following CLI tools:navai-generate-mobile-loaders
Generates module loaders for your mobile voice agent functions and routes:- Reads
.envand process environment variables - Resolves
NAVAI_FUNCTIONS_FOLDERSandNAVAI_ROUTES_FILE - Scans source files and selects matching modules
- Includes route module and referenced screen modules
- Writes output to
src/ai/generated-module-loaders.ts
--project-root <path>- Project root directory--src-root <path>- Source code root directory--output-file <path>- Output file path--env-file <path>- Custom .env file path--default-functions-folder <path>- Default functions folder--default-routes-file <path>- Default routes file--type-import <module>- Custom type import--export-name <identifier>- Custom export name
Quick Start
Use the React hook in your React Native application:Verification
Run the module loader generator to verify your setup:src/ai/generated-module-loaders.ts was created successfully. The file should export:
Test on Device/Simulator
Run your app on iOS or Android:Next Steps
Mobile Configuration
Configure runtime options, WebRTC transport, and permissions
Mobile Tools
Create local voice agent tools for your mobile application
Routes & Navigation
Set up route definitions for natural language navigation
API Reference
Explore the full mobile API documentation