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();

useOryxCurrentStage

Returns the current workflow stage for the message being processed.

This hook must be used within Oryx.Message.Agent to read the current stage properly.

tsx

const { currentStage } = useOryxCurrentStage();

useOryxToolCalls

Returns tool call information for the current message, including filtering helpers.

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

tsx

const { toolCalls, hasToolCalls, activeToolCalls, completedToolCalls, failedToolCalls } = useOryxToolCalls();

useOryxToolCallItem

Returns the tool call data for the current item.

This hook must be used within Oryx.ToolCalls.List.

tsx

const { toolCall } = useOryxToolCallItem();

useOryxThinking

Returns thinking/reasoning step information for the current message.

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

tsx

const { thinkingSteps, hasThinking, activeThinking, completedThinking, currentThinking } = useOryxThinking();

useOryxThinkingStepItem

Returns the thinking step data for the current item.

This hook must be used within Oryx.Thinking.List.

tsx

const { thinkingStep } = useOryxThinkingStepItem();

useOryxWorkflowSteps

Returns workflow step information for the current message.

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

tsx

const { workflowSteps, hasWorkflowSteps, activeSteps, completedSteps, failedSteps, currentStep } = useOryxWorkflowSteps();

useOryxWorkflowStepItem

Returns the workflow step data for the current item.

This hook must be used within Oryx.WorkflowSteps.List.

tsx

const { workflowStep } = useOryxWorkflowStepItem();

useOryxIntermediateSteps

Returns all intermediate steps (tool calls, thinking, workflow) in chronological order. Useful for building a unified activity log or trajectory view.

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

tsx

const { steps, hasSteps, currentStage } = useOryxIntermediateSteps();

Backtrack

Proxy Customization

Read Next

Advanced Usage

© 2025 Contextual AI, Inc.

Proudly open sourced under the Apache 2.0 license.