skills/copilotkit-setup/references/framework-detection.md
Detect the project's framework before generating any setup code. The detection order matters -- check more specific signals first.
1. Does `angular.json` exist?
YES -> Angular
NO -> continue
2. Does `next.config.{js,ts,mjs}` exist?
YES -> Next.js (go to step 3)
NO -> continue to step 4
3. Does an `app/` directory exist at the project root or under `src/`?
YES -> Next.js App Router
NO -> Does a `pages/` directory exist at the project root or under `src/`?
YES -> Next.js Pages Router
NO -> Next.js App Router (assume App Router for new projects)
4. Does `vite.config.{js,ts}` exist AND does `package.json` list `react` as a dependency?
YES -> Vite + React
NO -> Unknown / standalone backend only
src/app/api/copilotkit/[[...slug]]/route.ts (multi-route) or src/app/api/copilotkit/route.ts (single-route)"use client" page or layout componentGET and POST using handle(app) from hono/vercellayout.tsx: import "@copilotkit/react/styles.css".env.localhono (for Hono adapter)pages/_app.tsx or a page component. Must be a client component (default in Pages Router).runtimeUrl points to the Express server (e.g., http://localhost:4000/api/copilotkit)pages/_app.tsx or styles/globals.css: import "@copilotkit/react/styles.css".env.localuseSingleEndpoint must be set on the provider when using single-route Express endpoints@copilotkit/angular (separate package)CopilotKitProvider or React hooksangular.json@copilotkit/angular instead of @copilotkit/reactApp.tsx componentruntimeUrl points to the backend servermain.tsx or App.tsx: import "@copilotkit/react/styles.css".env (Vite exposes vars prefixed with VITE_)VITE_ -- they belong on the backend server, not exposed to the browser@copilotkit/runtime and @copilotkit/agent@copilotkit/react or @copilotkit/corecreateCopilotEndpointExpress (multi-route) or createCopilotEndpointSingleRouteExpress (single-route), both from @copilotkit/runtime/express.env (loaded via dotenv)createCopilotEndpoint or createCopilotEndpointSingleRoute from @copilotkit/runtime@hono/node-server with serve({ fetch: app.fetch, port })When implementing framework detection in a skill, check these files:
# Next.js
ls next.config.{js,ts,mjs} 2>/dev/null
# App Router vs Pages Router
ls -d app src/app 2>/dev/null # App Router
ls -d pages src/pages 2>/dev/null # Pages Router
# Angular
ls angular.json 2>/dev/null
# Vite + React
ls vite.config.{js,ts} 2>/dev/null
grep -q '"react"' package.json 2>/dev/null
# Package manager
ls pnpm-lock.yaml 2>/dev/null && echo "pnpm"
ls yarn.lock 2>/dev/null && echo "yarn"
ls package-lock.json 2>/dev/null && echo "npm"
ls bun.lockb 2>/dev/null && echo "bun"