hono
4.13.19 · 16 Nov 2026MIT114.5M / weekRepositoryHomepagenpmAtom feed
4.13.19 is the newest release of 4.x.
In short
14 new16 faster2 fixed2 internal
Security
10 advisories affect 4.13.0; 4.13.16 fixes them
- ModerateHono: `csrf()` does not check requests sent by hyperlink auditing (`text/ping`)GHSA-46wx-v44x-9hh2 · 12 Nov 2026Fixed in 4.13.16
- ModerateHono: `validator('form')` skips validation for `multipart/form-data` requests with extra parametersGHSA-4h7h-rv7c-7m2v · 12 Nov 2026Fixed in 4.13.16
- ModerateHono: `mount()` and `app.mount()` can forward a path that bypasses middleware scoped inside the mount prefixGHSA-4m76-xfj5-7975 · 12 Nov 2026Fixed in 4.13.16
- ModerateHono: RegExpRouter skips wildcard middleware for some route sets and for paths with an encoded line terminatorGHSA-h7mg-cq63-vhpq · 12 Nov 2026Fixed in 4.13.16
- ModerateHono: `serveStatic` decodes the request path a second time, leading to bypass of middleware on static pathsGHSA-5r4p-p66f-jhc7 · 20 Oct 2026Fixed in 4.13.11
5 more
- Moderatehono/jsx renders plain strings unescaped in boundary components, leading to XSSGHSA-hxh3-vqpv-xpqv · 30 Sep 2026Fixed in 4.13.7
- ModerateHono: Incomplete fix for CVE-2026-39408: `toSSG()` still writes files outside the output directoryGHSA-gqvv-2mrq-wpjv · 8 Sep 2026Fixed in 4.13.5
- ModerateHono: Unbounded dot-notation nesting in `parseBody()` can cause memory exhaustionGHSA-g6gw-c38x-mqfc · 8 Sep 2026Fixed in 4.13.5
- ModerateHono: Query parser reads parameters after the URL fragment, causing cache-key and proxy interpretation differentialsGHSA-crvj-82cr-hjcx · 8 Sep 2026Fixed in 4.13.5
- LowHono: `css` helper does not escape a closing tag split between the template and an interpolated value, allowing HTML injectionGHSA-3gg2-335m-rxc6 · 12 Nov 2026Fixed in 4.13.16
Release note
Hono v4.13.0 is now available!
The highlight of this release is performance: a batch of low-level optimizations makes the core request/response path significantly faster — up to 1.25x on common routes in our benchmark. This release also adds first-class support for the HTTP QUERY method, defined in RFC 10008, a new Method Not Allowed middleware, and more.
Performance improvements
This release includes a series of small optimizations: skipping unnecessary Headers allocations, replacing regex tests with indexOf, allocating internal state lazily, and more.
Here is benchmarks/fetch comparing v4.12 and v4.13 (ROUNDS=5 ./compare.sh, Bun 1.4.0, Apple Silicon — each measurement runs in a fresh process, and the variant order is reversed every round to avoid warm-up bias):
| Benchmark | v4.12 | v4.13 | Speedup |
|---|---|---|---|
ping — GET / | 165.83 ns | 163.99 ns | 1.01x |
query — GET /id/1?name=bun | 674.40 ns | 616.99 ns | 1.09x |
json — GET /user | 528.99 ns | 422.44 ns | 1.25x |
body — POST /json | 1.16 µs | 1.00 µs | 1.15x |
The individual changes:
context: Iterate the header record with
for..in#5118url: Replace regex tests with
indexOf#5121context: Skip
Headerscreation when there are no headers to merge #5122urls: Refactor
tryDecodeURIComponent#5158request: Allocate
#validatedDatalazily #5175request: Probe the body cache without allocating #5176
In addition, the RegExpRouter rewrite described below makes route registration plus the first match roughly 20% faster.
Thanks @kibertoad for the contributions!
First-class QUERY method support
The QUERY method — a safe, idempotent method that carries a request body — is now a first-class citizen in Hono. You can define QUERY handlers with app.query():
const app = new Hono()
app.query('/search', async (c) => {
const conditions = await c.req.json()
return c.json(await search(conditions))
})Thanks @shellhaki!
QUERY support across built-in middleware
The built-in middleware has been updated to handle QUERY requests properly:
Cache Middleware
The Cache Middleware now caches QUERY responses. Following RFC 10008 Section 2.7, the cache key incorporates a SHA-256 digest of the request content and its representation metadata, so different query bodies are cached separately:
app.query(
'/search',
cache({
cacheName: 'search-cache',
cacheControl: 'max-age=3600',
})
)Note: To support this, the internal cache key format has changed for all methods, including GET. Cached entries are now stored under an internal URL of the form /.hono/cache?__hono_cache_key=.... If you purge cache entries by URL outside of the middleware (e.g. calling caches.delete() with the original request URL), you will need to update that logic. Existing cache entries stored with the old format will simply be re-fetched.
ETag Middleware
The ETag Middleware now handles conditional requests for QUERY, returning 304 Not Modified when If-None-Match matches.
CORS Middleware
The CORS Middleware now includes QUERY in the default Access-Control-Allow-Methods, which is now GET, HEAD, PUT, POST, DELETE, PATCH, QUERY. If you specify allowMethods explicitly, nothing changes for you.
Method Not Allowed Middleware
The new Method Not Allowed Middleware returns a 405 Method Not Allowed response with a proper Allow header when the request path matches a registered route but the method does not:
import { methodNotAllowed } from 'hono/method-not-allowed'
const app = new Hono()
app.use(methodNotAllowed({ app }))
app.get('/hello', (c) => c.text('Hello!'))
app.post('/hello', (c) => c.text('Posted!'))
// PUT /hello -> 405 Method Not Allowed
// Allow: GET, HEAD, POSTYou can customize the response with the onMethodNotAllowed option:
app.use(
methodNotAllowed({
app,
onMethodNotAllowed: (c, methods) =>
c.json({ error: 'Method Not Allowed' }, 405, { Allow: methods.join(', ') }),
})
)Thanks @usualoma!
RegExpRouter throws UnsupportedPathError at registration time
The RegExpRouter now detects unsupported path combinations when routes are registered, instead of at the first matching request. This means misconfigured routes fail fast at startup rather than at runtime. As a bonus, registration plus the first match is roughly 20% faster.
Thanks @usualoma!
Other improvements
hono/utils/headershas been synced with the IANA HTTP Field Name Registry, adding newly registered fields such asAccept-Query. Thanks @akahoshi1421!The JWT and JWK middleware now accept a
realmoption for theWWW-Authenticatechallenge on401responses, and challenge values are properly escaped. Thanks @arhxam!JSX:
useRefandRefObjectare now aligned with React 19. Note that this is a type-level change —RefObject<T>is now{ current: T }, so type a nullable ref asRefObject<T | null>, and passuseRef(undefined)instead ofuseRef(). Thanks @ashunar0!JSX: A function component can now return an array of children without throwing during server-side rendering. Thanks @natsuki-engr!
The Compress Middleware now sets
Vary: Accept-Encodingon negotiated responses. Thanks @arhxam!
All changes
hono-base: Avoid rest parameter in
fetchcontext: Iterate the header record with for..in
url/request: Replace regex tests with
indexOfcontext: Skip Headers creation when there are no headers to merge
urls: Refactor
tryDecodeURIComponentcontext: Drop the throwaway
envfield initializerrequest: Allocate
#validatedDatalazilyrequest: Probe the body cache without allocating
hono-base: Restore the rest parameter in
fetchcontext: Restore the
envfield initializerAdd first-class QUERY method support
etag: Support conditional requests for the QUERY method
cors: Allow QUERY by default as a first-class method
cache: Add first-class support for QUERY requests
jsx: Add React-compatible overloads to useRef
middleware: Add method-not-allowed middleware
jwt,jwk: Add a configurable WWW-Authenticate realm
utils/headers: Sync HTTP field types with the IANA registry
jsx: Allow a function component to return an array
reg-exp-router: Throw UnsupportedPathError during route registration
compress: Set Vary: Accept-Encoding on negotiated responses
Thank you to all contributors!
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.