@xuna-ai/react package gives you hooks and providers to build completely custom voice interfaces in React. Use it when you need control the widget doesn’t provide — custom UI, client-side tools, dynamic overrides, or fine-grained state management.
Installation
- npm
- yarn
- pnpm
@xuna-ai/react re-exports everything from @xuna-ai/client, so you only need one dependency.
Minimal example
Wrap your app inConversationProvider, then use hooks inside it to start and stop sessions.
ConversationProvider
PlaceConversationProvider at the root of any component tree that needs access to conversation state. It accepts the following props:
Hooks
Use granular hooks to avoid unnecessary re-renders. Each hook subscribes only to the state it needs.useConversationControls
Session lifecycle and messaging actions.useConversationStatus
Current connection state.useConversationInput
Microphone mute control.useConversationMode
Whether the agent is speaking or listening.useConversationFeedback
Submit session feedback.useConversationClientTool
Register a client tool from inside a component. The tool name must match what you configured for the agent in the dashboard.useConversation
Combines all hooks in one. Convenient for simple components, but causes more re-renders than using granular hooks.startSession options
Pass options tostartSession to control how the session connects.
Authenticating private agents
If your agent is private, generate a credential on your server and pass it tostartSession. Choose WebSocket (signed URL) or WebRTC (conversation token) based on your stack.
- WebSocket — signed URL
- WebRTC — conversation token
ServerClient
Client tools
Client tools let the agent call functions in your React app during a conversation — for example, to display information, submit a form, or navigate the UI. Define them onConversationProvider or register them with useConversationClientTool.
Overrides
Passoverrides to startSession to customize agent behavior for a specific session without changing the agent’s dashboard configuration.
Server location
By default, conversation servers are located in the US. SetserverLocation on ConversationProvider to use a different region.
Next steps
- To deploy without a custom UI, use the widget instead.
- For mobile apps, see the Mobile SDKs page.
- To build a fully custom integration outside React, use the WebSocket API.

