Commit Graph

3 Commits

Author SHA1 Message Date
Benjamin Taylor b53edc0a6e docs: drop the hono dependency and the deprecated endpoint alias
The earlier commits in this PR taught `createCopilotEndpoint` paired with
`handle` from `hono/vercel`, and added `hono` to 20 install commands with a
callout explaining why readers must install it. Both were wrong, and the second
was a consequence of the first.

`createCopilotEndpoint` is a **deprecated alias**. This repo's own handler table
says so — `docs/backend/runtime-endpoints.mdx`:

    | Deprecated                          | Use instead                |
    | `createCopilotEndpoint`             | `createCopilotHonoHandler` |
    | `createCopilotEndpointSingleRoute`  | ... with mode: "single-route" |

`createCopilotRuntimeHandler` serves the same multi-route mode (it is the
default), returns a plain fetch handler, is not deprecated, and needs **no hono
at all**. So the route collapses to:

    const handler = createCopilotRuntimeHandler({
      runtime,
      basePath: "/api/copilotkit",
    });

    export const GET = handler;
    export const POST = handler;

`hono` was therefore an artifact of the shape, not a requirement of the library.
The install lines and the callout are reverted; nothing tells readers to install
it any more.

## Verified with hono deleted, not merely absent from package.json

`examples/shadcn` converted to this shape, `hono` removed from its
`package.json`, and `node_modules/hono` deleted outright so a hoisted copy could
not mask the result:

    GET  /api/copilotkit/info              -> 200
    POST /api/copilotkit/agent/default/run -> 200, chat turn rendered
    tsc --noEmit / eslint / next build     -> clean
    next build route                       -> ƒ /api/copilotkit/[[...slug]]

The doctest sidecar drops `hono` too, so the CI gate now typechecks the
canonical snippet against `@copilotkit/runtime` alone — proof by construction
that the snippet needs nothing else.

    pnpm tsx scripts/doc-tests/run.ts   -> 2 passed, 0 failed
    showcase/shell-docs: typecheck      -> exit 0
    showcase/shell-docs: build          -> exit 0
    structural audit: 31/31 mdx files, fence + JSX identical to HEAD

## Also corrected

`docs/backend/custom-agent.mdx` repeated the same incorrect transport claim the
earlier commit fixed in four other places ("Both `<CopilotKit>` and
`<CopilotKitProvider>` negotiate the transport when the prop is omitted").
Corrected to match released behaviour.

## Left alone deliberately

`snippets/shared/backend/custom-agent.mdx` and `docs/backend/custom-agent.mdx`
still call `createCopilotEndpoint` in three fences each, as
`export default copilotEndpoint` — the Hono-app deployment pattern rather than a
Next.js route handler. That predates this PR, the documented replacement is
`createCopilotHonoHandler`, and I have not run that shape. Recorded as follow-up
rather than guessed at. (The two files have also drifted from each other, which
is a separate problem.)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 08:32:30 -05:00
Benjamin Taylor 0be2aac315 fix(examples): move shadcn onto the v2 multi-route runtime endpoint
`examples/shadcn` paired a v1, POST-only runtime route with a
`@copilotkit/react-core/v2` frontend. `GET /api/copilotkit` answered 405 and
`GET /api/copilotkit/info` did not route at all (404), so nothing could probe
the runtime.

Convert the route to the v2 multi-route shape at a catch-all path, exporting
both verbs:

  app/api/copilotkit/[[...slug]]/route.ts
  createCopilotEndpoint({ runtime, basePath: "/api/copilotkit" })
  export const GET = handle(app)
  export const POST = handle(app)

Two co-changes this shape requires, both found by running the app rather than
by reading it:

- `hono` becomes a direct dependency. It is a dependency of
  `@copilotkit/runtime`, not a peer, so under pnpm's strict layout
  `import { handle } from "hono/vercel"` does not resolve from the app
  without declaring it.
- the provider must pass `useSingleEndpoint={false}`. The published
  `<CopilotKit>` from `@copilotkit/react-core/v2` defaults to the
  single-route transport, which posts a single-route envelope to the bare
  basePath; a multi-route runtime answers that with 404. The runtime says so
  itself in the error body.

`@copilotkit/*` moves 1.61.2 -> 1.68.3 so the app runs the versions a reader
installing today would get.

Verified live (aimock on :4010 as the model backend):
  GET  /api/copilotkit/info              -> 200, runtime /info payload
  POST /api/copilotkit/agent/default/run -> 200, chat turn renders
  before: GET /api/copilotkit -> 405, GET /api/copilotkit/info -> 404
  tsc --noEmit, eslint, next build all clean

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 08:32:29 -05:00
Tyler Slaton 0759f63aae example(shadcn): add example using new components and shadcn primatives
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-06-26 17:37:06 -07:00