Skip to main content
The Pipecat React SDK provides hooks for accessing client functionality, managing media devices, and handling events.

usePipecatClient

Provides access to the PipecatClient instance originally passed to PipecatClientProvider. Returns PipecatClient | undefined, which is undefined outside a provider.

useRTVIClientEvent

Allows subscribing to RTVI client events. It is advised to wrap handlers with useCallback.
Arguments
RTVIEvent
required
function
required

usePipecatClientMediaDevices

Manage and list available media devices.

useMediaState

Subscribes to the per-device mic and cam state, re-rendering when either transitions. Use it to drive permission UI.
Returns a MediaState snapshot. Safe to call from any component inside PipecatClientProvider: the subscription is mounted for you.

useMediaSupport

Subscribes to which kinds of media can flow in the session, re-rendering when that changes. Use it to hide controls for media the transport or bot doesn’t support.
Returns a MediaSupport snapshot. Safe to call from any component inside PipecatClientProvider: the subscription is mounted for you.

useBotCapabilities

Returns the bot’s BotCapabilities from its bot-ready message, or undefined until the bot is ready, after disconnecting, and for bots that don’t send capabilities.
Safe to call from any component inside PipecatClientProvider: the subscription is mounted for you.

usePipecatClientMediaTrack

Access audio and video tracks.
Arguments
'audio' | 'video' | 'screenAudio' | 'screenVideo'
required
'bot' | 'local'
required
Returns the MediaStreamTrack, or null until one has started.

usePipecatClientAudioElement

Returns a RefObject<HTMLAudioElement> to attach to your own <audio> element, which then plays the bot’s audio track. It is what PipecatClientAudio renders: it retries playback on the user’s first click, tap, or keypress when the browser blocks autoplay, and follows speaker changes with setSinkId.

usePipecatClientScreenShareControl

Controls the local participant’s screen share state.
Starting a share opens the browser’s own picker, so call enableScreenShare(true) from a user gesture. Render the result with PipecatClientVideo using trackType="screenVideo", or reach the raw track through tracks().

usePipecatClientTransportState

Returns the current transport state.

usePipecatClientCamControl

Controls the local participant’s camera state.

usePipecatClientMicControl

Controls the local participant’s microphone state.

useDTMF

Sends DTMF keypresses to the bot: the digits a caller would press on a phone keypad.
sendTone takes a single key or a sequence ("123#"), and wraps sendDTMF(), so the same validation and protocol requirements apply. It is a no-op until a client is available from PipecatClientProvider.

usePipecatConversation

The primary hook for accessing the conversation message stream. Returns the current list of messages (ordered for display) and a function to inject messages programmatically. Each assistant message’s text parts are split into spoken and unspoken segments based on real-time speech progress, so you can style them differently (e.g. dim unspoken text).
Options
(message: ConversationMessage) => void
Called once when a new message first enters the conversation. The message may or may not be complete at this point; check message.final.
(message: ConversationMessage) => void
Called whenever an existing message’s content changes (e.g. streaming text appended, function call status changed, message finalized). Check message.final to detect finalization.
Record<string, OutputTypeMetadata>
Metadata for output types to control rendering and speech progress behavior. Used to determine which output types should be excluded from position-based speech splitting.
Record<string, OutputTypeMetadata>
deprecated
Deprecated. Use outputTypeMetadata instead. Where both have an entry for an output type, the outputTypeMetadata entry is used.
BotOutputFilter
Restrict which bot output reaches messages, as { spoken?: boolean; unspoken?: boolean }. Use it to render only what the bot says aloud, or only the text it produces without speaking.
boolean
default:"false"
Include backchannels: short acknowledgments said while the other side talks, such as the user’s “mhm” or the bot’s “Mm-hmm.” (RTVI 2.2.0+). Each is its own message with backchannel: true, placed by when it was said, and is also reported to onMessageCreated.
Returns
ConversationMessage[]
The current list of conversation messages, ordered for display. Assistant messages have their text parts split into { spoken, unspoken } based on real-time speech progress.
(message: { role: 'user' | 'assistant' | 'system'; parts: ConversationMessagePart[] }) => void
Programmatically inject a message into the conversation (e.g. a system prompt or user-typed input).
(text: string, options?: SendTextOptions) => Promise<string>
Sends text to the bot and adds it to the conversation as a user message. The message’s status is sent, then received once the bot acknowledges it, or failed if it couldn’t be sent. Bots before RTVI 2.2.0, or with user input turned off, never acknowledge text, so their messages stay sent. Use it in place of injectMessage plus client.sendText(), not alongside them. Resolves to the ID of the send-text message, also the message’s msgId.
BotOutputEvent[]
The raw bot-output events behind messages, in arrival order. Useful for debugging or replaying how a response was assembled.

useConversationContext

Lower-level hook that provides direct access to the conversation context. Use this when you only need injectMessage without subscribing to the message stream, or to check whether the connected bot supports BotOutput events.
Returns
(message: { role: 'user' | 'assistant' | 'system'; parts: ConversationMessagePart[] }) => void
Programmatically inject a message into the conversation.
(text: string, options?: SendTextOptions) => Promise<string>
Sends text to the bot and adds it to the conversation as a user message with a status of sent, received or failed.
boolean | null
Whether the connected bot supports BotOutput events (RTVI 1.1.0+). null means detection hasn’t completed yet.

Conversation Utilities

Helpers the conversation store uses, exported for building your own message lists from ConversationMessage[]:

User Interface

These hooks voice-enable a UI: stream the screen to a server-side UIWorker, send UI events, handle the bot’s UI commands, and track background work. They must be used within a PipecatClientProvider. See the RTVI standard for wire payloads and Controlling the UI for the patterns.

useUISnapshot

Streams accessibility snapshots of the page to the bot. Call once near the root of your app.
Arguments: options?: UseUISnapshotOptions with enabled (default true), debounceMs (default 300), trackViewport (default true), and logSnapshots (default false).

useUIEventSender

Returns (event: string, payload?) => void to send app-defined UI events to the bot (routed to the worker’s @ui_event handlers).

useUICommandHandler

Registers a handler for a named UI command, active while the component is mounted.
Arguments
string
required
(payload: T) => void | Promise<void>
required

Default Command Handlers

useDefaultUICommandHandlers(options?) installs DOM handlers for all the standard commands at once (scroll_to, focus, highlight, select_text, set_input_value, click). Each resolves the target by snapshot ref, then target_id, and refuses unsafe targets. Install them individually with useDefaultScrollToHandler, useDefaultFocusHandler, useDefaultHighlightHandler, useDefaultSelectTextHandler, useDefaultSetInputValueHandler, and useDefaultClickHandler. For the non-DOM commands, useToastHandler(handler) and useNavigateHandler(handler) are typed convenience wrappers.
Options: useDefaultUICommandHandlers takes one options object per handler, and each individual hook takes the matching object.
DefaultScrollToOptions
DefaultFocusOptions
DefaultHighlightOptions
DefaultSelectTextOptions
DefaultSetInputValueOptions

useUIJobGroups

Reads accumulated job groups (oldest first) and controls from the nearest UIJobGroupsProvider. Without one, it returns no groups and its controls do nothing. Wrap your app in the provider to collect them:
Returns: UIJobGroupsAPI: groups: JobGroup[], cancelJobGroup(jobId, reason?), dismissJobGroup(jobId), and clearCompleted(). Each JobGroup has jobId, label, cancellable, status, startedAt, completedAt, and jobs (per-worker { workerName, status, startedAt, completedAt, updates, response }).