@fishaudio/agent-react wraps the Web SDK in idiomatic React: a useConversation hook for session control, an optional provider that shares one session across your component tree, and a ready-made audio visualizer. The SDK handles microphone capture, audio playback, and transport internally — you write UI.
Web SDK reference
Every event, method, and error code.
Authentication
Create session tokens on your backend.
Public agents
Connect with just an agent id, no backend.
Install
Quick start
A minimal call UI: start a call, show what the agent is doing, mute, hang up. This example connects to a public agent by id.App.tsx
status, mode, and isSpeaking are React state — your component re-renders as the conversation progresses. When the component unmounts, the session ends automatically.
Call
startSession from a user gesture (such as a click handler) so the
browser allows microphone capture and audio playback.Connect to a private agent
For agents that are not public, your backend creates the session with your API key (POST /v1/agent/sessions) and returns the response to the browser. Pass it to startSession unchanged.
startSession accepts the same options as AgentSession.start in the Web SDK, including clientTools. Session settings such as overrides and dynamicVariables apply when you connect with an agentId; with a sessionToken, your backend sets them in its session-creation request instead.
What useConversation returns
For transcripts, tool-call events, and error handling, subscribe to events on
session — see the Web SDK event reference.
Share one session across components
Wrap your tree inAgentSessionProvider when several components need the same conversation — call controls in the header, a transcript panel elsewhere.
App.tsx
useAgentSessionContext() instead of calling useConversation themselves — it returns the same fields, so the quick-start CallButton only needs its hook call swapped.
Audio visualizer
<AgentAudioVisualizer> renders animated canvas bars driven by the agent’s output audio — a drop-in “the agent is talking” indicator. Inside an AgentSessionProvider it picks up the active session automatically; elsewhere, pass a session prop. Optional bars, width, height, and className props control the rendering, and the bars follow the element’s CSS color.
useAudioLevels or the session’s frequency-data methods from the Web SDK.
Going further
Web SDK
Full event and method reference behind these hooks.
Client tools
Let the agent call functions in your app.
Authentication
Create session tokens server-side for private agents.
Dynamic variables
Personalize each session at start time.

