The Pipecat React SDK provides hooks for accessing client functionality, managing media devices, and handling events.Documentation Index
Fetch the complete documentation index at: https://daily-mb-ui-agent.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
usePipecatClient
Provides access to thePipecatClient instance originally passed to PipecatClientProvider.
useRTVIClientEvent
Allows subscribing to RTVI client events. It is advised to wrap handlers withuseCallback.
usePipecatClientMediaDevices
Manage and list available media devices.usePipecatClientMediaTrack
Access audio and video tracks.usePipecatClientTransportState
Returns the current transport state.usePipecatClientCamControl
Controls the local participant’s camera state.usePipecatClientMicControl
Controls the local participant’s microphone state.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 intospoken and unspoken segments based on real-time speech progress, so you can style them differently (e.g. dim unspoken text).
Called once when a new message first enters the conversation. The message may
or may not be complete at this point — check
message.final.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.Metadata for aggregation types to control rendering and speech progress
behavior. Used to determine which aggregations should be excluded from
position-based speech splitting.
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.Programmatically inject a message into the conversation (e.g. a system prompt or user-typed input).
useConversationContext
Lower-level hook that provides direct access to the conversation context. Use this when you only needinjectMessage without subscribing to the message stream, or to check whether the connected bot supports BotOutput events.
Programmatically inject a message into the conversation.
Whether the connected bot supports BotOutput events (RTVI 1.1.0+).
null
means detection hasn’t completed yet.UI Agent hooks
These hooks use thePipecatClient from the ambient
PipecatClientProvider.
For the full client/server pattern, including snapshots, commands, and task
lifecycle, see the UI Agent guide.
useUIEventSender
Returns a callable that sends a named UI event to the server. The returned function is a no-op until aPipecatClient is available.
Function that emits a UI event with the given event name and optional payload.
useUICommandHandler
Register a handler for a named UI command. The handler is registered on mount and unregistered on unmount; if the handler reference changes between renders, the registration is refreshed. Pass a stable reference (viauseCallback) to avoid per-render churn.
App-defined command name, matching what the server emits via
UIAgent.send_command.Callback invoked with the command payload.
useUISnapshot
Capture a structured accessibility snapshot of the document and stream it to the server as a first-classui-snapshot RTVI message. The server-side
UIAgent stores the latest
snapshot and renders it into LLM context as <ui_state> so the agent can
reason about what’s on screen.
Call once near the root of your app, inside a PipecatClientProvider. This hook
is a thin lifecycle wrapper around
PipecatClient.startUISnapshotStream;
non-React apps should use the managed client method directly.
- Emits an initial snapshot shortly after mount.
- Re-emits on DOM mutations, ARIA attribute changes, focus changes,
scroll-end, window resize, tab visibility change, and text selection changes,
coalesced by
debounceMs. - No-op until a
PipecatClientis available from the ambientPipecatClientProvider.
Whether the hook is active. Set to
false to stop emitting snapshots without
unmounting the component.Minimum interval between snapshot emissions, in milliseconds.
When
true, annotate every emitted node with "offscreen" in its state
list if its bounding rect sits entirely outside the viewport.When
true, log each emitted snapshot to the browser console (node count,
rough token estimate, raw tree).useDefaultScrollToHandler
Install the defaultscroll_to handler: scrollIntoView on the resolved
target. Resolves by snapshot ref first, then falls back to
document.getElementById(target_id).
scrollIntoView block position.scrollIntoView inline position.Fallback scroll behavior when
payload.behavior is unset.When set, scroll inside this element instead of relying on
scrollIntoView
walking to the nearest scrollable ancestor. Function form is evaluated on each
scroll so it can account for containers mounted after the hook.Pixel offsets applied after scrolling, typically to clear a sticky header.
Only applied when
container is set.useDefaultFocusHandler
Install the defaultfocus handler: .focus() on the resolved target.
Pass
{ preventScroll: true } to element.focus() so the focus change
doesn’t also pan the viewport. Useful when focus happens alongside an
explicit scroll_to.useDefaultHighlightHandler
Install the defaulthighlight handler: toggle a CSS class on the resolved
target for duration_ms. Apps style the class themselves, e.g.
CSS class toggled on the target for
duration_ms.Fallback duration when
payload.duration_ms is missing.When
true, the target is scrolled into view before the class is applied, so
the flash is visible to the user even if the target is currently offscreen.useDefaultSelectTextHandler
Enable the defaultselect_text handler. Resolves the target by ref / target_id and applies the page text selection (Range.selectNodeContents for document elements, el.select() for <input> / <textarea>). With start_offset / end_offset set, walks descendant text nodes to apply a sub-range selection.
When true, scroll the target into view before applying the selection so the
user actually sees what was selected.
scrollIntoView block position when scrolling first.useDefaultSetInputValueHandler
Enable the defaultset_input_value handler. Resolves the target by ref / target_id; refuses on disabled, readonly, and <input type="hidden"> (silent no-op so the agent can’t bypass UI affordances the user is meant to control), then assigns el.value and dispatches single-shot input and change events so React-controlled inputs and vanilla onChange listeners pick up the new value naturally.
With replace: false on the payload, the new text is appended to the current value; the default replaces. The flag is ignored for native <select> since a select either has the value or doesn’t. Native <select> is supported alongside text inputs and textareas (the handler sets el.value and dispatches change).
When true, fire
focus() on the target before writing so the user sees the
cursor land in the field. The element is blurred after the change events fire
to avoid stealing keyboard focus mid-conversation.useDefaultClickHandler
Enable the defaultclick handler. Resolves the target by ref / target_id and calls el.click(). Silently no-ops on disabled and aria-disabled="true" targets so the agent can’t bypass UI affordances meant to be user-controlled.
useDefaultUICommandHandlers
Install all DOM-based default handlers (scroll_to, focus, highlight,
select_text, set_input_value, click) at once. Pass per-handler option
objects to customize.
Forwarded to
useDefaultScrollToHandler.Forwarded to
useDefaultFocusHandler.Forwarded to
useDefaultHighlightHandler.Forwarded to
useDefaultSelectTextHandler.Forwarded to
useDefaultSetInputValueHandler.useDefaultClickHandler takes no options and is always installed.
useToastHandler
Typed sugar foruseUICommandHandler<ToastPayload>("toast", handler). Wire
a toast renderer of your choice; the SDK doesn’t ship one.
useNavigateHandler
Typed sugar foruseUICommandHandler<NavigatePayload>("navigate", handler).
Wire into your router of choice; the SDK doesn’t ship one.
useUITasks
Subscribe to the in-flight task-group state surfaced by the server’sui-task lifecycle envelopes. Returns the live list of task groups plus methods to cancel and prune task groups.
For live task state, mount a UITasksProvider inside PipecatClientProvider. The provider listens to RTVIEvent.UITask envelopes from the underlying PipecatClient and reduces them into groups state.
Live array of in-flight and recently completed task groups, in arrival order.
Each group has
taskId, label, status ("running" / "completed" /
"cancelled" / "error"), cancellable, timestamps, and per-worker
entries with status, progress updates, and response.Ask the server to cancel the named task group. Forwards to
PipecatClient.cancelUITask.
Honored only when the group was registered with cancellable=True on the
server.Remove a non-running group from local UI state. Running groups are kept.
Remove every non-running group from local UI state.
UITasksProvider is mounted, useUITasks returns an empty groups list and no-op methods rather than throwing.