Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Hono Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-hono-knowledge-patch)
---
name: hono-knowledge-patch
description: Hono
version: "4.13.23"
license: MIT
metadata:
author: Nevaberry
---
# Hono Knowledge Patch
Load this skill when updating Hono routing, authentication, runtime adapters,
RPC and validation, rendering, streaming, static generation, or CLI workflows.
Use the topic references for complete guidance and examples.
## Reference index
| Reference | Topics |
| --- | --- |
| [Routing and requests](references/routing-and-requests.md) | Mount migration, route introspection, QUERY and HEAD, router constraints, body reuse, query parsing, context |
| [Security and authentication](references/security-and-auth.md) | JWT/JWK algorithms and verification, Basic and Bearer Auth, CORS, CSRF, cookies, headers, IP restrictions, body limits |
| [Client, RPC, validation, and testing](references/client-rpc-validation-testing.md) | Response types and parsing, URLs, serialization, request options, validators, project references, test clients |
| [Middleware, runtimes, and integrations](references/middleware-runtimes-integrations.md) | Adapter migration, WebSockets, static files, cache keys, ETags, compression, negotiation, proxies, MCP, third-party packages |
| [Rendering, streaming, and static generation](references/rendering-streaming-ssg.md) | JSX boundaries and hooks, CSS, SSR isolation, streaming errors, SSE, SSG plugins and output |
| [Hono CLI](references/cli.md) | Installation, documentation search, Markdown docs, in-process requests, development servers, route builds |
## Breaking changes and deprecations
### Runtime adapter imports
Starting in 4.13.10, install adapters separately and switch imports to
`@hono/bun`, `@hono/deno`, `@hono/cloudflare-workers`, `@hono/aws-lambda`,
`@hono/lambda-edge`, `@hono/netlify`, `@hono/vercel`, or `@hono/service-worker`.
The `hono/<adapter>` imports still work in v4, are deprecated, and are scheduled
for removal in v5.
```diff
- import { serveStatic } from 'hono/bun'
+ import { serveStatic } from '@hono/bun'
```
`@hono/bun` is ESM only; `@hono/deno` is also available on JSR.
The migration path for deprecated `hono/cloudflare-pages` is Workers with static assets.
`app.fire()` is deprecated; register the app as the Service Worker request handler with `fire(app)`.
### Mount middleware
Starting in 4.13.13, replace `app.mount('/legacy', handler)` with
`app.all('/legacy/*', mount(handler))` using `mount` from `hono/mount`.
`app.mount()` is deprecated in v4 and scheduled for removal in v5.
```ts
import { Hono } from 'hono'
import { mount } from 'hono/mount'
const app = new Hono()
const handler = (request: Request) => new Response(new URL(request.url).pathname)
app.all('/legacy/*', mount(handler))
```
Starting in 4.13.16, mount paths reject suffix wildcards such as `/assets*` and
duplicate parameter names; 4.13.18 also rejects optional regex parameters.
Use 4.13.22 or later for corrected forwarding when a custom `getPath` prepends
a prefix and for the `400` response if forwarding would change the path's meaning.
Starting in 4.13.14, a custom `getPath` cannot be combined with `strict: false`.
### Verification algorithms, RPC methods, refs, and cache keys
Starting in 4.11.4, `jwt()` requires a single `alg`; `jwk()` requires an `alg`
array of allowed asymmetric algorithms. Match the issuer's signing configuration.
```ts
import { jwt } from 'hono/jwt'
import { jwk } from 'hono/jwk'
app.use('/session/*', jwt({ secret, alg: 'HS256' }))
app.use('/api/*', jwk({ jwks_uri: 'https://issuer.example.com/jwks.json', alg: ['RS256'] }))
```
- In 4.11.5, `ClientRequest` drops `$all`; call a concrete method such as `$get()` or `$post()`.
- `RefObject<T>` has `current: T`; include null explicitly with `RefObject<T | null>` and give `useRef` an initial value such as `useRef(undefined)`.
- `cache()` keys for all methods, including GET, use `/.hono/cache?__hono_cache_key=...`. Update purge logic that looks up entries by the original URL; expect misses for entries stored before the upgrade.
- QUERY cache keys include a SHA-256 digest of the request body and its representation metadata.
- Legacy SSG hook options are deprecated. Register new hooks through SSG plugins.
## Security and routing conditions
- After upgrading to 4.13.16, regenerate `PreparedRegExpRouter` data for the wildcard middleware fix. Custom route patterns that match an empty string throw `UnsupportedPathError`.
- Use 4.13.23 or later for TrieRouter with arbitrary HTTP method names, Bun behind a path-filtering reverse proxy, or `except()` with alternation in a route parameter constraint. Each alternative must match the complete parameter in both `except()` and TrieRouter constraints.
- Starting in 4.13.11, `serveStatic()` rejects paths still containing `%` after decoding. To serve literal `%` filenames, set `allowPercentInPath: true`. Starting in 4.13.18, this option still returns `404` if decoding would make the file path differ from the path Hono routed.
- Use 4.13.21 or later with relative `hc` base URLs so route parameter values cannot change the destination host.
- JWT verification rejects a header containing `crit` starting in 4.13.16; starting in 4.13.21, signatures must use canonical unpadded base64url encoding with zero unused bits.
- Starting in 4.13.22, `basicAuth()` throws at setup unless `username` and `password` are strings. Check the corresponding environment variables before calling it.
- Use 4.13.18 or later to keep `bodyLimit()` memory use bounded by `maxSize` when buffering chunked request bodies.
- Use 4.12.25 or later and configure an explicit trusted origin for credentialed CORS, such as `cors({ credentials: true, origin: 'https://app.example.com' })`.
## Routing and request access
Use `matchedRoutes(c)` from `hono/route` for matched handlers and `routePath(c)`
for the current route pattern. In mounted handlers, `routePath(c)` is the local
pattern, `baseRoutePath(c)` is the base route pattern, and `basePath(c)` is the
mount prefix with parameters filled in. `routePath(c, index)` and
`baseRoutePath(c, index)` follow `Array.prototype.at()` indexing, including middleware matches.
Register safe, idempotent requests with bodies through `app.query()` and read
the body with request methods such as `c.req.json()`.
`methodNotAllowed({ app })` from `hono/method-not-allowed` returns 405 when the
path matches a route but the method does not. Its default `Allow` header includes
HEAD for GET routes; customize the response with `onMethodNotAllowed(c, methods)`.
Hono dispatches HEAD through GET routes, bypasses dedicated HEAD registrations,
and drops the response body. The GET handler and its middleware still see
`c.req.method === 'HEAD'`.
Use `cloneRawRequest` from `hono/request` with `c.req` to obtain a raw `Request`
with a readable body after a validator or middleware consumes it through Hono.
Starting in 4.12.32, parsed query, header, and route parameter maps have a null
prototype; check keys with `Object.hasOwn(c.req.query(), 'page')`.
## RPC and validation
Pass an `hc` call to `parseResponse` from `hono/client` to parse the body according
to its `Content-Type`. A non-OK response throws `DetailedError`.
```ts
import { parseResponse } from 'hono/client'
const body = await parseResponse(client.hello.$get())
```
Typed responses returned by middleware registered inline with a route join the
final handler's RPC response union. Narrow the body type by checking `res.status`.
Use `ApplyGlobalResponse` for responses from `app.onError()` or global middleware;
the helper is exported from `hono/client` in 4.12.1, with route-schema preservation
fixed in 4.12.4. Augment `NotFoundResponse` and register a matching `app.notFound()`
handler to include the declared 404 body when a route returns `c.notFound()`.
Pass an absolute base URL as the second type argument to `hc` for exact `$url()`
types. `$path()` returns a string containing the path and any query string, taking
`param` and `query` as `$url()` does. `hc` does not URL-encode `param` values:
use `encodeURIComponent()` for `/` within one segment or a route such as `:path{.+}`
when the parameter should span segments.
Set `buildSearchParams` in `hc` options for custom query serialization.
Pass Fetch options as `{ init: { signal } }` in a client call's second argument.
`init` fields take precedence over generated request options; `init.headers`
replaces assembled headers, including generated `Content-Type`.
The `json` and `form` validators pass `{}` when `Content-Type` does not match.
Set the header explicitly in `app.request()` tests sending a JSON string.
Starting in 4.13.18, parameter formatting in `Content-Type` does not affect parser
selection. Header validators use lowercase keys such as `value['idempotency-key']`.
`testClient()` accepts `hc()` client options.
## Authentication options and response headers
Set `headerName` for custom JWT or JWK token headers. Starting in 4.12.21, both
middleware require the Bearer scheme when reading from `Authorization`.
`verifyOptions.iss` on `jwt()` accepts an issuer string or regular expression;
`verifyOptions.nbf`, `verifyOptions.iat`, and `verifyOptions.exp` default to `true`
and check the corresponding claims when present.
Set `allow_anon: true` in `jwk()` to admit requests without a token;
`c.get('jwtPayload')` identifies an authenticated request when a payload is present.
JWK `keys` and `jwks_uri` can be functions receiving the request's Hono context.
Use `verifyWithJwks` to verify against a JSON Web Key Set outside the middleware.
Starting in 4.13.19, `secureHeaders({ overwrite: false })` preserves existing
security headers. CSP reporting uses `contentSecurityPolicy.reportTo` or
`contentSecurityPolicy.reportUri` in `secureHeaders()`.
## Rendering and streaming
Wrap streamed JSX in `StreamingContext` with `value={{ scriptNonce }}` to apply
the nonce to scripts generated by `Suspense` and `ErrorBoundary`; use the same
per-response nonce in the CSP header.
Use 4.12.27 or later for per-request JSX SSR context isolation and 4.12.34 or later
for the separate fix isolating `memo()` output across requests.
Exceptions inside streaming callbacks bypass `app.onError`. Pass
`(error, stream) => ...` as the helper's optional third argument to handle failures
in the stream. Hono logs them to the console by default and closes the stream after
the callbacks finish. Starting in 4.13.22, the helpers accept synchronous `onError` callbacks.
Check `stream.aborted` in long-running `streamSSE()` loops to stop after disconnects.
Starting in 4.12.31, `writeSSE()` emits `retry: 0` when specified; starting in
4.12.32, `id: ''` emits an empty event ID field to reset the client's last event ID.
`hono/jsx/dom` includes `useFormStatus()`, `useActionState()`, and `useOptimistic()`.
Use 4.13.20 or later for React 19–aligned `useActionState()` behavior.
## Static generation
Pass `SSGPlugin` objects through `toSSG()`'s `plugins` option.
`afterGenerateHook(result, fsModule, options)` receives generated files through
`result.files` and can write additional output. `beforeRequestHook` and
`afterResponseHook` accept a function or an array of functions; return a `Request`
or `Response` to continue, or `false` to skip the route before dispatch or the file after dispatch.
The implicit `defaultPlugin()` generates files only for HTTP 200 responses.
Include it explicitly with a custom `plugins` array to retain that filter.
Put `redirectPlugin()` before `defaultPlugin()` to generate redirect HTML pages
for 301, 302, 303, 307, and 308 responses.
```ts
import fs from 'node:fs/promises'
import { defaultPlugin, redirectPlugin, toSSG } from 'hono/ssg'
app.get('/old', (c) => c.redirect('/new', 301))
app.get('/new', (c) => c.html('New page'))
await toSSG(app, fs, { plugins: [redirectPlugin(), defaultPlugin()] })
```
## CLI quick reference
```sh
npm i @hono/cli
hono search "basic auth"
hono docs /docs/middleware/builtin/basic-auth
hono request -P /api/users -X POST -d '{"name":"Alice"}' src/index.ts
hono serve --use 'logger()' --use "serveStatic({ root: './public' })" src/index.ts
hono optimize src/index.ts
```
`hono search` writes matching documentation URLs and paths as JSON; `hono docs`
writes a page's Markdown. `hono request [file]` calls a default-exported Hono app,
defaults to `src/index.ts` and `GET /`, and writes response status and body as JSON.
`hono serve [entry]` defaults to `http://localhost:7070`.
`hono optimize src/index.ts` writes `dist/index.js` with a `PreparedRegExpRouter`
precomputed for the app's routes.