Back

React Hooks_Oryx

Oryx provides a set of React hooks for managing chat state, message metadata, retrieval information, and streaming status. All hooks are exported from @contextualai/oryx-react.

useOryx

The primary hook for managing Oryx chat state and streaming lifecycle. Returns control functions and a probe object to pass into Oryx.Root.

tsx

const { probe, start, stop, states } = useOryx({ fetcher });

return <Oryx.Root probe={probe}>{/* ... */}</Oryx.Root>;

Parameters:

Returns:

useOryxStatus

Exposes the streaming status and error state for the current message.

This hook must be used within Oryx.Message.Agent to read the status of the current message properly.

tsx

const { isStreaming, error } = useOryxStatus();

useOryxMessage

Returns identifiers and state for the current message.

This hook must be used within Oryx.Message.Agent to read the metadata of the current message properly.

tsx

const { messageId, requestId, conversationId, state } = useOryxMessage();

return (
  <ul>
    <li>Message ID: {messageId}</li>
    <li>Request ID: {requestId}</li>
    <li>Conversation ID: {conversationId}</li>
  </ul>
);

useOryxRetrievals

Returns the list of retrievals for the current message.

This hook must be used within Oryx.Message.Agent to access retrievals properly.

tsx

const { retrievals } = useOryxRetrievals();

useOryxRetrievalItem

Returns the retrieval data for the current item.

This hook must be used within Oryx.Retrievals.List or Oryx.Retrievals.RawList.

tsx

const { retrieval } = useOryxRetrievalItem();

useOryxContext

Low-level hook to access the root Oryx context directly. Useful for building custom integrations outside the standard component tree.

Prefer using useOryx for standard use cases. This hook is for advanced scenarios only, where you want to avoid passing helper functions deeply into the component tree, or want to access all states directly.

tsx

const { states, start, stop } = useOryxContext();

Backtrack

Proxy Customization

Read Next

Advanced Usage

© 2025 Contextual AI, Inc.

Proudly open sourced under the Apache 2.0 license.