Path A · recommended for apps
Add CopilotKit to a project with npm
Works with Next.js (App Router), React Router, TanStack Start or a plain single-page React app.
-
Scaffold or install
For a new project, run the CLI. For an existing app, install the packages.
# new project npx copilotkit@latest create # existing app npm install @copilotkit/react-core \ @copilotkit/runtime
-
Expose the runtime endpoint
Add a server route, usually
/api/copilotkit, that runs CopilotRuntime with your agent. Keep model API keys in server environment variables. -
Mount the provider and styles
import { CopilotKitProvider, CopilotSidebar, } from "@copilotkit/react-core/v2"; import "@copilotkit/react-core/v2/styles.css"; -
Optional: give your coding agent the docs
npx copilotkit@latest skills install