Skip to main content

React SDK

@kapaai/agent-react provides a complete chat UI with streaming, tool execution, and theming. It includes @kapaai/agent-core as a dependency, so you only need to install one package.

Installation

npm install @kapaai/agent-react

Components

ComponentDescription
AgentProviderWraps your app with chat state and theming. Required.
AgentChatFull chat UI: header, messages, input, footer. Fills its parent container.
AgentPanelSlide-in drawer wrapping AgentChat.
AgentFooterAttribution footer with optional custom content via branding.footerExtra.

Hooks

HookDescription
useAgentChat()Access chat state and actions (messages, sendMessage, approveToolCall, etc.). Required for headless mode.
useAgentColorScheme()Toggle or set the color scheme. See Theming.

Utilities

ExportDescription
createToolHelper<TContext>()Type-safe tool definition factory with Zod inference for execute and render args. See Custom tools.

Headless mode

You can use AgentProvider + useAgentChat() without any SDK UI components to build a fully custom chat interface. See Headless mode for the pattern and the full useAgentChat() reference.

Lower-level components

These components are also exported for advanced customization. They require AgentProvider for theming context:

ComponentDescription
AgentInputTextarea with send/stop button.
AgentMessageBubbleRenders a single message (user bubble, assistant markdown, or error alert).
ToolCallCardExpandable tool call card with args/response/sources tabs.
ToolCallGroupContainer for grouping tool cards.
SourceTilesSource attribution tiles with favicons.
ExamplePromptsStarter prompt buttons for empty conversations.
ShimmerTextAnimated shimmer text for loading states.
AgentThreadHistoryConversation history list. Used automatically by AgentChat. Render directly only for custom layouts.