copilotkit-nextjs-integration

Integrate CopilotKit into Next.js apps to build context-aware AI copilots with state sharing and actions.

2.1k|244|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/raphaelmansuy/edgequake --skill copilotkit-nextjs-integration-raphaelmansuy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: copilotkit-nextjs-integration
Source: https://github.com/raphaelmansuy/edgequake/tree/main/.github/skills/copilotkit-nextjs-integration
Command: npx skills add https://github.com/raphaelmansuy/edgequake --skill copilotkit-nextjs-integration-raphaelmansuy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @copilotkit/react-core, @copilotkit/runtime, @copilotkit/react-ui, and includes references (resource) components.

What problem does it solve? Building AI copilots that understand your app's UI state and can trigger real actions requires wiring together chat UIs, LLM providers, streaming endpoints, and tool execution. This Skill provides the patterns and step-by-step instructions to integrate CopilotKit into a Next.js application without assembling that plumbing from scratch. ## Core Features & Use Cases - Runtime Endpoint Setup: Create a /api/copilotkit route with built-in adapters for OpenAI, Groq, or Google, plus custom adapter patterns for self-hosted LLMs like Ollama or LM Studio. - State Sharing & Actions: Expose app data to the model with useCopilotReadable and let the model trigger state mutations or backend API calls with useCopilotAction. - Production Hardening: Add authentication, parameter validation, logging, streaming timeouts, and retry logic to the runtime endpoint. - Use Case: A SaaS dashboard where a copilot reads the visible CRM records and, on user request, updates deal statuses through a validated action handler. ## Quick Start Set up a CopilotKit runtime endpoint and add a basic chat popup to my Next.js app.

Frequently Asked Questions about copilotkit-nextjs-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add CopilotKit to a Next.js app?

Install @copilotkit/react-core, @copilotkit/runtime, and @copilotkit/react-ui, create a POST route at /api/copilotkit using CopilotRuntime with an adapter like OpenAIAdapter, then wrap your root layout in the CopilotKit provider with runtimeUrl pointing to that route.

How do I share React state with a CopilotKit copilot?

Use the useCopilotReadable hook with a description and a JSON-serializable value. The model receives that state as context, so it can answer questions grounded in your current UI data, such as a user list or task collection.

Can CopilotKit use a self-hosted LLM like Ollama?

Yes. Implement a custom CopilotServiceAdapter whose streamChatCompletion method calls your local endpoint, such as Ollama at localhost:11434 or LM Studio's OpenAI-compatible API, and pass that adapter to the runtime endpoint.

CopilotKit vs Vercel AI SDK for chat UIs?

CopilotKit focuses on agentic UIs with built-in hooks for readable state and model-triggered actions, while Vercel AI SDK is simpler for plain chat without UI-state tooling. Choose CopilotKit when the model must read and mutate app state.

Why does CopilotKit streaming time out on Vercel?

Serverless functions have default execution limits that cut off long streaming responses. Set maxDuration to 60 seconds in your route or next.config, and consider a faster adapter like Groq to reduce response latency.

When should I not use CopilotKit?

Avoid it for standalone backend AI with no UI state synchronization, for enterprise-scale orchestration across many systems, and for non-React frontends. It is an app-level React framework, not a distributed workflow engine.