Building AI-powered applications traditionally meant stitching together a chat UI, an AI backend, state management, and tool execution – all while ensuring the AI could actually interact with your application’s data and UI. CopilotKit solves this problem by providing a complete open-source stack for adding AI copilots to any React application, handling the complex plumbing of streaming AI responses, generative UI, and shared state so you can focus on the application logic.
With over 30,000 GitHub stars, CopilotKit has become the leading framework for building what the team calls “in-app AI.” Unlike standalone chatbots that operate in a separate window, CopilotKit’s copilots are deeply integrated into your application – they can read and modify application state, render custom UI components inside their responses, and execute actions that affect the actual application.
The magic happens through CopilotKit’s AG-UI protocol (Agentic Generative UI), an open specification for real-time communication between AI agents and UI components. This protocol enables AI to render dynamic forms, charts, and tables directly in the chat, and for user interactions with those components to flow back to the agent as context for the next action.
What Are CopilotKit’s Core Components?
CopilotKit provides a set of React components and hooks designed to work together seamlessly.
graph TD
A[CopilotKit\nRoot Provider] --> B[CopilotSidebar\nFull Chat Interface]
A --> C[CopilotPopup\nFloating Widget]
A --> D[useCopilotAction\nRegister Tools]
A --> E[useCopilotReadable\nExpose State]
A --> F[useCopilotChat\nProgrammatic Control]
B --> G[Your React App]
D --> H[Backend Agent\nLangChain / OpenAI / Custom]
E --> H
F --> H
H --> I[Generative UI\nRendered Components]
I --> J[User Interactions\nFlow Back to Agent]
| Component/Hook | Purpose | Configuration |
|---|---|---|
| CopilotKit (provider) | Root wrapper providing AI context to app | API endpoint, agent configuration |
| CopilotSidebar | Sidebar panel for in-depth AI conversations | Position, width, custom header |
| CopilotPopup | Floating chat bubble for quick interactions | Position, trigger element |
| useCopilotAction | Register tools and actions the AI can invoke | Name, description, parameters, handler function |
| useCopilotReadable | Expose application state to the AI | Description, state value, categories |
| useCopilotChat | Programmatic control over chat | Send message, set context, clear history |
How Does the AG-UI Protocol Work?
The AG-UI protocol is the architectural foundation that enables CopilotKit’s generative UI capabilities. It defines how AI agents and UI components communicate in real-time.
graph LR
A[AI Agent] -->|Streams UI definition\nJSON schema| B[AG-UI Protocol]
B -->|Renders component| C[React Component\nForm / Chart / Table]
C -->|User interacts| D[User Input]
D -->|Sends interaction\nback to agent| A
A -->|Updates state| E[Application State]
E -->|Readable by agent| A
| Protocol Feature | Description |
|---|---|
| UI streaming | Agent streams component definitions as JSON during response generation |
| Bi-directional events | User interactions with rendered UI flow back to the agent |
| State synchronization | Agent can read and modify application state through CopilotReadable |
| Tool execution | Agent can invoke any registered useCopilotAction tool |
| Response loading | Agent shows intermediate states while tools execute |
The protocol is designed to be framework-agnostic. While CopilotKit’s reference implementation targets React, the protocol itself can be implemented for any UI framework. This means your backend agents built with the AG-UI protocol can potentially serve multiple frontends.
What Frameworks and Integrations Does CopilotKit Support?
CopilotKit’s integration ecosystem covers both frontend frameworks and backend AI orchestration tools.
| Category | Supported Technologies |
|---|---|
| Frontend Frameworks | Next.js 14/15 (App Router + Pages Router), Vite + React, Remix, plain React |
| AI Orchestration | LangChain, LangGraph, LangServe, OpenAI Assistants API, custom API endpoints |
| Vector Stores | Pinecone, Chroma, Weaviate, Supabase, custom vector stores |
| LLM Providers | Claude (Anthropic), GPT-4o (OpenAI), Gemini (Google), local models via LangChain |
How Does CopilotKit Handle State Management?
CopilotKit’s state integration is one of its most powerful features. Through the useCopilotReadable hook, you expose parts of your application state to the AI. The AI can then reference this state naturally in conversations.
| State Aspect | Hook/Method | Example |
|---|---|---|
| Expose state to AI | useCopilotReadable | “Current cart has 3 items, total $45.20” |
| Register AI actions | useCopilotAction | “Add item to cart”, “Apply discount code” |
| Execute operations | Action handler function | API calls, database updates, form submissions |
| State sync | Automatic via React state | AI sees latest state after every change |
For example, if your e-commerce app exposes the shopping cart via useCopilotReadable, the AI copilot can answer questions like “What’s in my cart?”, “What’s the total?”, and – through registered actions – “Add the blue sweater in size medium to my cart.” The application state and the AI conversation stay in sync automatically.
Why Would You Use CopilotKit Instead of Building a Custom Chat UI?
Building a custom AI chat interface requires solving a series of non-trivial problems: streaming AI responses to the UI, parsing and rendering tool calls, handling generative UI, maintaining state synchronization, and managing conversation history. CopilotKit solves all of these out of the box.
| Concern | Custom Build | CopilotKit |
|---|---|---|
| Streaming responses | Manual SSE/WebSocket handling | Built-in, optimized streaming |
| Tool execution | Custom parser for tool calls | Declarative useCopilotAction |
| Generative UI | Custom protocol design | AG-UI protocol included |
| State sync | Manual state management | Automatic via useCopilotReadable |
| React rendering | Custom chat components | CopilotSidebar, CopilotPopup |
| Multi-model support | Custom adapter per model | LangChain integration |
For teams building production agentic applications, CopilotKit eliminates weeks of infrastructure work and provides battle-tested patterns for the most challenging aspects of AI UI integration.
FAQ
What is CopilotKit? CopilotKit is an open-source SDK with over 30,000 GitHub stars for building full-stack agentic AI applications. It provides React components and hooks that let you add in-app AI copilots with generative UI, shared application state management, and human-in-the-loop workflows. It abstracts the complexity of streaming AI responses, tool execution, and state synchronization between the AI and your application.
What are CopilotKit’s core components? CopilotKit has four core components: CopilotSidebar (chat sidebar that can read/write app state), CopilotPopup (floating chat widget for quick AI interactions), CopilotKit (root provider wrapping your app), and hooks like useCopilotAction (register tools the AI can call), useCopilotReadable (expose app state to the AI), and useCopilotChat (programmatic chat control).
What is the AG-UI protocol? The AG-UI (Agentic Generative UI) protocol is CopilotKit’s open specification for real-time communication between AI agents and UI components. It defines how agents can render dynamic UI elements (forms, charts, tables) within chat responses, how user interactions with those elements flow back to the agent, and how the agent can read and modify application state. The protocol is framework-agnostic and designed for interoperability.
What React frameworks does CopilotKit support? CopilotKit supports all major React frameworks including Next.js (App Router and Pages Router), Vite + React, Remix, and plain React. The SDK includes framework-specific optimizations for server-side rendering, streaming, and deployment. Support for Vue, Svelte, and other frameworks is available through the community or the AG-UI protocol implementation.
What integrations does CopilotKit support? CopilotKit integrates with multiple AI providers and services. For AI orchestration, it supports LangChain, LangGraph, LangServe, OpenAI Assistants API, and custom endpoints. For vector stores and retrieval, it integrates with Pinecone, Chroma, Weaviate, and Supabase. For LLMs, it supports any model accessible through LangChain or direct API integration, including Claude, GPT-4o, Gemini, and open-source models.
Further Reading
- CopilotKit GitHub Repository – Source code, issues, and examples
- CopilotKit Official Documentation – Setup guides, API reference, and tutorials
- AG-UI Protocol Specification – Open protocol for AI-to-UI communication
- CopilotKit Demo Applications – Example apps with source code