Installation
Core Concepts
CopilotKitProvider
TheCopilotKitProvider is the root component that manages the connection to your CopilotKit runtime and provides context to all child components.
Key Props
runtimeUrl- URL of your CopilotKit runtime endpointheaders- Custom headers to include in requestscredentials- Fetch credentials mode (e.g., “include” for cookies)publicApiKey- CopilotCloud public API keyshowDevConsole- Show developer console (“auto” shows on localhost)onError- Error handler for runtime and agent errorsrenderToolCalls- Array of tool call renderersfrontendTools- Array of frontend toolshumanInTheLoop- Array of human-in-the-loop tools
Using Agents
TheuseAgent hook connects to an agent and subscribes to its state changes.
Frontend Tools
Frontend tools allow the agent to execute functions in the browser. UseuseFrontendTool to register tools dynamically:
Tool Call Rendering
Render custom UI for tool executions usingdefineToolCallRenderer:
Agent Context
Provide dynamic context to your agent usinguseAgentContext:
Suggestions
Configure AI-generated suggestions usinguseConfigureSuggestions:
Chat Components
CopilotKit provides pre-built chat UI components:CopilotChat
The main chat interface component:CopilotSidebar
A sidebar variant of the chat interface:CopilotPopup
A popup/modal variant:Complete Example
Here’s a full example integrating CopilotKit in a Next.js application:TypeScript Support
CopilotKit is fully typed with TypeScript. Import types for custom implementations:Next Steps
Human-in-the-Loop
Learn how to add approval flows to your tools
Tool Development
Build custom tools for your agents
Agent Configuration
Configure and customize your agents
