Introduction
The@navai/voice-frontend package provides React hooks and utilities for integrating Navai voice agents into web applications. It handles the complete lifecycle of voice interactions, from authentication to function execution.
Installation
Core Features
Voice Agent Integration
TheuseWebVoiceAgent hook manages the entire voice agent lifecycle:
- Real-time connection management
- Backend authentication and function loading
- Route-based navigation
- Frontend and backend function execution
- Error handling and state management
Agent Building
ThebuildNavaiAgent function creates a configured OpenAI Realtime agent with:
- Navigation tools for route management
- Function execution capabilities
- Dynamic tool registration
- Conflict detection and warnings
Backend Client
ThecreateNavaiBackendClient provides HTTP client functionality for:
- Creating ephemeral client secrets
- Listing available backend functions
- Executing backend functions
Quick Start
Package Exports
Hooks
useWebVoiceAgent- Main React hook for voice agent integration
Agent Building
buildNavaiAgent- Create configured Realtime agentBuildNavaiAgentOptions- Agent configuration optionsBuildNavaiAgentResult- Agent build result with warnings
Backend Client
createNavaiBackendClient- Create HTTP client for backendNavaiBackendClient- Backend client interfaceCreateNavaiBackendClientOptions- Client configuration
Functions
loadNavaiFunctions- Load and register frontend functionsNavaiFunctionDefinition- Function definition typeNavaiFunctionsRegistry- Function registry typeNavaiFunctionModuleLoaders- Module loader map
Routes
resolveNavaiRoute- Resolve route name/path to pathgetNavaiRoutePromptLines- Generate route prompt textNavaiRoute- Route definition type
Types
See Types Reference for complete type definitions.Architecture
Next Steps
- useWebVoiceAgent Hook - Complete hook reference
- buildNavaiAgent - Agent building API
- Backend Client - HTTP client reference
- Functions - Function loading and execution
- Routes - Route resolution
- Types - TypeScript types