What is @navai/voice-frontend?
@navai/voice-frontend is a React SDK that provides voice-first navigation and function execution for web applications. It integrates with the OpenAI Realtime API to enable natural voice interactions that can navigate your app and execute frontend functions.
Key Features
- Voice Navigation: Navigate between routes using natural language
- Frontend Functions: Execute JavaScript functions via voice commands
- Backend Integration: Connect to backend functions through the NAVAI API
- React Hook: Simple
useWebVoiceAgenthook for React apps - Type-Safe: Full TypeScript support with type definitions
- Flexible Configuration: Runtime and build-time configuration options
Installation
The package requires React 18 or higher as a peer dependency.
Core Exports
React Hook
Agent Builder
Backend Client
Route Resolution
Function Loading
Quick Example
Architecture
The frontend SDK coordinates several components:- useWebVoiceAgent: React hook that manages the voice session lifecycle
- buildNavaiAgent: Creates an OpenAI RealtimeAgent with navigation and function tools
- createNavaiBackendClient: Handles API communication for secrets and backend functions
- Runtime Config: Resolves routes and functions from environment variables or defaults
- Route Resolution: Maps voice inputs to application routes
- Function Registry: Loads and executes frontend functions
Next Steps
React Web Hook
Learn how to use useWebVoiceAgent in your React app
Configuration
Configure routes, functions, and backend connection
UI Navigation
Define voice-navigable routes for your app
Local Functions
Create frontend functions callable via voice
