Skip to content
Back to skills

Hono Knowledge Patch

ASecurity

Hono

  • 25 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 5, 2026
developmenttypescriptrustgoreactexpressawstestingapisecuritydocumentation

Works with

  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill hono-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Hono Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Hono Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-hono-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-hono-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: hono-knowledge-patch
description: Hono
version: "4.13.23"
license: MIT
metadata:
  author: Nevaberry
---


# Hono compatibility guidance

Load this skill when writing or updating Hono routes, RPC clients, validation,
authentication, middleware, runtime adapters, JSX, streaming, static generation,
or CLI usage. The quick reference highlights migrations and commonly used APIs;
the topic references retain detailed behavior, examples, and fix requirements.

## Topic references

| Reference | Topics |
| --- | --- |
| [Routing and requests](references/routing-and-requests.md) | Mounting, route inspection, HTTP methods, router restrictions, request bodies, context |
| [Client, RPC, validation, and testing](references/client-rpc-validation-testing.md) | Response types, URLs, serialization, validators, project types, test clients |
| [Security and authentication](references/security-and-auth.md) | JWT/JWK, Basic/Bearer Auth, cookies, CORS/CSRF, security headers, body limits, IP restrictions |
| [Middleware, runtimes, and integrations](references/middleware-runtimes-integrations.md) | Adapter migration, WebSockets, Lambda, static files, caching, ETags, compression, negotiation, integrations |
| [Rendering, streaming, and static generation](references/rendering-streaming-ssg.md) | JSX, DOM hooks, CSS, SSE, streaming errors, SSG plugins and output |
| [Hono CLI](references/cli.md) | Installation, documentation search, in-process requests, serving, optimized builds |

## Migrations and changed requirements

### Runtime adapters and mounted handlers

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 corresponding `hono/<adapter>` imports still work in v4, are deprecated,
and are scheduled for removal in v5. `@hono/bun` is ESM only;
`@hono/deno` is also on JSR. The deprecated `hono/cloudflare-pages`
adapter's migration path is Workers with static assets.

Starting in 4.13.13, replace `app.mount('/legacy', handler)` with
`app.all('/legacy/*', mount(handler))`, importing `mount` from `hono/mount`.
The method is deprecated in v4 and scheduled for removal in v5.
`app.fire()` is deprecated: import `fire` from `hono/service-worker`
and call `fire(app)`; the adapter-package migration above also applies.

### Authentication algorithms and credential types

Starting in 4.11.4, `jwt()` requires one `alg`, and `jwk()` requires an
`alg` array of allowed asymmetric algorithms. Match the issuer's signing setup.

```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'] }))
```

Starting in 4.12.21, JWT/JWK middleware require the Bearer scheme when reading
`Authorization`. Starting in 4.13.22, `basicAuth()` throws at setup unless
`username` and `password` are strings; check that environment variables are set.

### Cache keys, client methods, refs, and SSG hooks

`cache()` keys for all methods, including GET, use
`/.hono/cache?__hono_cache_key=...`. Update purge logic that looks up the
original URL and expect misses for entries stored before this change.
QUERY keys include a SHA-256 digest of the body and its representation metadata.

In 4.11.5, `ClientRequest` drops `$all`; call `$get()`, `$post()`, or another
concrete method. `RefObject<T>` has `current: T`: include null explicitly
with `RefObject<T | null>` and give `useRef` an initial value such as
`useRef(undefined)`.

Legacy SSG hook options are deprecated. Register hooks through SSG plugins.
When providing a custom `plugins` array, include `defaultPlugin()` explicitly
to retain the HTTP-200-only output filter.

## Routing and request security requirements

Starting in 4.13.14, a custom `getPath` cannot be combined with `strict: false`.
Use strict routing with a custom path resolver. Mount paths reject suffix
wildcards such as `/assets*` and duplicate parameter names starting in 4.13.16;
4.13.18 also rejects optional regex parameters. Use 4.13.22 or later for
corrected forwarding when custom `getPath` prepends a prefix, and for a `400`
response if forwarding would change the path's meaning.

After upgrading to 4.13.16, regenerate `PreparedRegExpRouter` data for the
wildcard middleware fix. Custom route patterns matching 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. Set `allowPercentInPath: true` to serve filenames with a literal `%`.
Starting in 4.13.18, that option still returns `404` if decoding would make the
file path differ from the routed path. Starting in 4.13.14, static serving
handles only `GET` and `HEAD`.

Use 4.13.18 or later to keep `bodyLimit()` memory use bounded by `maxSize`
when buffering chunked request bodies. Use 4.13.21 or later with relative
`hc` base URLs so route parameter values cannot change the destination host.

## RPC and validation quick reference

Pass a client call to `parseResponse` from `hono/client` to parse by
`Content-Type`; a non-OK response throws `DetailedError`.
Inline route middleware's typed responses join the final handler's response
union. Check `res.status` to narrow the body type.

Use `ApplyGlobalResponse` for `app.onError()` or global middleware responses;
it is exported from `hono/client` in 4.12.1, with route-schema preservation
fixed in 4.12.4. Use `PickResponseByStatusCode` to select a status's response type.
Augment `NotFoundResponse` and register a matching `app.notFound()` handler
so routes returning `c.notFound()` include the declared 404 body in RPC types.

Pass an absolute base URL as `hc`'s second type argument to preserve protocol,
host, and route path in `$url()`'s type. Use `$path()` for a string containing
path and query, passing `param` and `query` as with `$url()`.
`hc` inserts parameter values without URL-encoding: use `encodeURIComponent()`
for a slash within one segment, or a server parameter such as `:path{.+}`
when it should span segments.

Set `buildSearchParams` to customize query serialization; `$ws()` also uses it.
Pass Fetch options in the second call argument as `{ init: { signal } }`.
`init` takes precedence: `init.headers` replaces assembled headers, including
generated `Content-Type`. Starting in 4.13.20, merging `init` preserves
class instances such as `Headers`.

The `json` and `form` validators pass `{}` to the callback without a matching
`Content-Type`. Explicitly set the header in `app.request()` JSON-string tests.
Starting in 4.13.18, parser selection uses the media type alone, ignoring
formatting differences in its parameters. Header validator keys are lowercase.
For separate TypeScript projects, add a reference from client to server
to consume the exported `AppType`. `testClient()` accepts `hc()` options.

## Routes, requests, and middleware quick reference

Register safe, idempotent requests with bodies using `app.query()`.
`methodNotAllowed({ app })` from `hono/method-not-allowed` returns 405 for a
registered path with an unmatched method; its default `Allow` includes HEAD
for GET routes. Customize the response with `onMethodNotAllowed(c, methods)`.
HEAD dispatch uses GET routes, bypasses dedicated HEAD registrations, and
drops the response body; handlers and middleware still see `c.req.method === 'HEAD'`.

Use `matchedRoutes(c)`, `routePath(c)`, `baseRoutePath(c)`, and `basePath(c)`
from `hono/route` for route inspection. Indexed pattern helpers follow
`Array.prototype.at()` conventions. In mounted handlers, `routePath(c)`
is local and `basePath(c)` fills mount parameters from the request.

Use `cloneRawRequest(c.req)` from `hono/request` after middleware or validators
consume a body through Hono. Parsed query, header, and route parameter maps
have null prototypes; use `Object.hasOwn(c.req.query(), 'page')` to check a key.

`cacheableStatusCodes: [200, 404]` makes both statuses eligible for caching.
Cache skips `Cache-Control: private` or `no-store`, and responses varying on
`Authorization` or `Cookie`. Configured `vary` header values enter the cache key.
Use `onCacheNotAvailable` for runtimes without the Cache API.
`etag()` returns 304 for QUERY with matching `If-None-Match`; the non-wildcard
case skips unsafe methods and error responses starting in 4.13.1.

## Authentication and browser protections

Use `headerName` for custom JWT/JWK token headers. Set `allow_anon: true` in
`jwk()` to let requests without tokens reach the handler; a present `jwtPayload`
identifies an authenticated request. JWK `keys` and `jwks_uri` can be functions
that receive the request's Hono context. Supply the required `alg` settings above.

Set `verifyOptions.iss` on `jwt()` to an issuer string or regular expression.
The `nbf`, `iat`, and `exp` verification flags default to true and check
claims when present. Starting in 4.13.19, `verifyOptions.typ` checks the JWT
header type. Verification rejects headers containing `crit` starting in
4.13.16; 4.13.21 requires canonical unpadded base64url signatures with zero unused bits.

Use 4.12.25 or later and an explicit trusted origin for credentialed CORS.
`csrf()` exempts OPTIONS preflights and, starting in 4.13.16, checks
`Origin` and `Sec-Fetch-Site` on `text/ping` hyperlink auditing requests.
Use `secureHeaders({ overwrite: false })` to preserve existing security headers.

## Rendering, streaming, and static generation

Wrap streaming JSX in `StreamingContext` with `value={{ scriptNonce }}` to
apply a nonce to scripts generated by `Suspense` and `ErrorBoundary`.
Use that same per-response nonce in the CSP header. Use 4.13.7 or later to
HTML-escape plain-string children or fallbacks of `Suspense`, `ErrorBoundary`,
or `Context.Provider` where applicable, and plain-string roots of
`renderToString()` or `renderToReadableStream()` from `hono/jsx/dom/server`.

Test `stream.aborted` in long-running `streamSSE()` loops.
Streaming callback exceptions bypass `app.onError`; handle them in the
streaming helper's optional third argument, `(error, stream) => ...`.
By default Hono logs errors and closes the stream after callbacks finish.
Starting in 4.13.22, `onError` may be synchronous.

`hono/jsx/dom` includes `useFormStatus()`, `useActionState()`, and
`useOptimistic()`. Use 4.13.20 or later for React 19–aligned `useActionState()`.
In `hono/jsx`, `useViewTransition()` returns `[isUpdating, startViewTransition]`;
`viewTransition()` from `hono/jsx/dom/css` generates a unique transition name.

Pass `SSGPlugin` objects to `toSSG()`. `beforeRequestHook` and `afterResponseHook`
accept functions or arrays of functions. Return `false` to skip the route
before dispatch or the file after dispatch, respectively.
Put `redirectPlugin()` before `defaultPlugin()` for redirect pages.
Use 4.13.5 or later to keep `ssgParams` output inside the configured directory.

## CLI quick reference

Install with `npm i @hono/cli`. `hono search "basic auth"` returns documentation
URLs and site paths as JSON; `hono docs /docs/middleware/builtin/basic-auth`
prints Markdown. `hono request [file]` requests a default-exported app and prints
status and body as JSON; defaults are `src/index.ts` and `GET /`.
Set path with `-P`, method with `-X`, and body with `-d`.

`hono serve [entry]` defaults to `http://localhost:7070`; repeat `--use` for
middleware expressions. Omitting entry serves an empty app that returns 404
unless middleware handles the request. `hono optimize src/index.ts` writes
a deployable `dist/index.js` with precomputed `PreparedRegExpRouter` data.

Files in this skill

  • SKILL.md8.9 KB
  • coverage.json1.3 KB
  • references/cli.md1.7 KB
  • references/client-rpc-validation-testing.md4.7 KB
  • references/middleware-runtimes-integrations.md4 KB
  • references/rendering-streaming-ssg.md5.5 KB
  • references/routing-and-requests.md3.6 KB
  • references/security-and-auth.md5.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.