hono
4.13.19 · 16 Nov 2026MIT114.5M / weekRepositoryHomepagenpmAtom feed
4.13.19 is the newest release of 4.x.
In short
16 new7 faster2 fixed1 changed
Security
41 advisories affect 4.12.0; 4.13.16 fixes them
- Highhono: CORS Middleware reflects any Origin with credentials when `origin` defaults to the wildcardGHSA-88fw-hqm2-52qc · 16 Jun 2026Fixed in 4.12.25
- HighHono vulnerable to arbitrary file access via serveStatic vulnerability GHSA-q5qw-h33p-qvwr · 4 Mar 2026Fixed in 4.12.4
- HighHono is Vulnerable to Authentication Bypass by IP Spoofing in AWS Lambda ALB conninfoGHSA-xh87-mx6m-69f3 · 25 Feb 2026Fixed in 4.12.2
- 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
36 more
- 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/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
- ModerateHono: `memo()` retains SSR output across requests, leading to cross-user data disclosureGHSA-f23p-vx2j-j53r · 7 Aug 2026Fixed in 4.12.34
- ModerateHono: Algorithmic Complexity DoS in Language MiddlewareGHSA-54fx-42gc-7vw4 · 7 Aug 2026Fixed in 4.12.34
- ModerateHono: ReDoS in CORS middleware via Access-Control-Request-HeadersGHSA-8j4g-w8fx-2239 · 3 Aug 2026Fixed in 4.12.34
- Moderatehono/jsx does not isolate context per request, leading to cross-request data disclosureGHSA-hvrm-45r6-mjfj · 21 Jul 2026Fixed in 4.12.27
- ModerateHono: Server-Side XSS via JSX Escaping Bypass in cx() UtilityGHSA-w62v-xxxg-mg59 · 21 Jul 2026Fixed in 4.12.27
- ModerateHono: API Gateway v1 adapter can drop a distinct repeated request header value during de-duplicationGHSA-xgm2-5f3f-mvvc · 21 Jul 2026Fixed in 4.12.27
- Moderatehono: Body Limit Middleware can be bypassed on AWS Lambda by understating `Content-Length`GHSA-rv63-4mwf-qqc2 · 16 Jun 2026Fixed in 4.12.25
- Moderatehono: Lambda@Edge adapter keeps only the last value of a repeated request header, dropping the restGHSA-wgpf-jwqj-8h8p · 16 Jun 2026Fixed in 4.12.25
- Moderatehono: Path traversal in `serve-static` on Windows via encoded backslash (`%5C`)GHSA-wwfh-h76j-fc44 · 16 Jun 2026Fixed in 4.12.25
- Moderatehono: AWS Lambda adapter merges multiple `Set-Cookie` headers into one value, dropping cookies on ALB single-header and LatticeGHSA-j6c9-x7qj-28xf · 16 Jun 2026Fixed in 4.12.25
- ModerateHono: app.mount() strips mount prefix using undecoded path, causing incorrect routing for percent-encoded pathsGHSA-2gcr-mfcq-wcc3 · 4 Jun 2026Fixed in 4.12.21
- ModerateHono: IP Restriction bypasses static deny rules for non-canonical IPv6 GHSA-xrhx-7g5j-rcj5 · 4 Jun 2026Fixed in 4.12.21
- ModerateHono: Cookie helper does not sanitize sameSite and priority, allowing Set-Cookie injectionGHSA-3hrh-pfw6-9m5x · 4 Jun 2026Fixed in 4.12.21
- ModerateHono: JWT middleware accepts any Authorization scheme, not only BearerGHSA-f577-qrjj-4474 · 4 Jun 2026Fixed in 4.12.21
- ModerateHono has CSS Declaration Injection via Style Object Values in JSX SSRGHSA-qp7p-654g-cw7p · 9 May 2026Fixed in 4.12.18
- ModerateHono's Cache Middleware ignores Vary: Authorization / Vary: Cookie leading to cross-user cache leakageGHSA-p77w-8qqv-26rm · 9 May 2026Fixed in 4.12.18
- ModerateHono: bodyLimit() can be bypassed for chunked / unknown-length requestsGHSA-9vqf-7f2p-gf9v · 6 May 2026Fixed in 4.12.16
- Moderatehono/jsx has Unvalidated JSX Tag Names that May Allow HTML InjectionGHSA-69xw-7hcm-h432 · 6 May 2026Fixed in 4.12.16
- Moderatehono Improperly Handles JSX Attribute Names Allows HTML Injection in hono/jsx SSRGHSA-458j-xx4x-4375 · 16 Apr 2026Fixed in 4.12.14
- ModerateHono: Non-breaking space prefix bypass in cookie name handling in getCookie()GHSA-r5rp-j6wh-rvv4 · 8 Apr 2026Fixed in 4.12.12
- ModerateHono has incorrect IP matching in ipRestriction() for IPv4-mapped IPv6 addressesGHSA-xpcf-pg52-r92g · 8 Apr 2026Fixed in 4.12.12
- ModerateHono missing validation of cookie name on write path in setCookie()GHSA-26pp-8wgv-hjvm · 8 Apr 2026Fixed in 4.12.12
- ModerateHono: Path traversal in toSSG() allows writing files outside the output directoryGHSA-xf4j-xp2r-rqqx · 8 Apr 2026Fixed in 4.12.12
- ModerateHono: Middleware bypass via repeated slashes in serveStaticGHSA-wmmm-f939-6g9c · 8 Apr 2026Fixed in 4.12.12
- ModerateHono vulnerable to Prototype Pollution possible through __proto__ key allowed in parseBody({ dot: true })GHSA-v8w9-8mx6-g223 · 11 Mar 2026Fixed in 4.12.7
- ModerateHono Vulnerable to Cookie Attribute Injection via Unsanitized domain and path in setCookie()GHSA-5pq2-9x2x-5p6w · 4 Mar 2026Fixed in 4.12.4
- ModerateHono Vulnerable to SSE Control Field Injection via CR/LF in writeSSE()GHSA-p6xx-57qc-3wxr · 4 Mar 2026Fixed in 4.12.4
- 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
- LowHono: Proxy Helper does not remove response headers listed in the `Connection` headerGHSA-79qm-7rj5-m7r9 · 7 Aug 2026Fixed in 4.12.34
- LowHono has improper validation of NumericDate claims (exp, nbf, iat) in JWT verify()GHSA-hm8q-7f3q-5f36 · 9 May 2026Fixed in 4.12.18
Release note
Release Notes
Hono v4.12.0 is now available!
This release includes new features for the Hono client, middleware improvements, adapter enhancements, and significant performance improvements to the router and context.
$path for Hono Client
The Hono client now has a $path() method that returns the path string instead of a full URL. This is useful when you need just the path portion for routing or key-based operations:
const client = hc<typeof app>('http://localhost:8787')
// Get the path string
const path = client.api.posts.$path()
// => '/api/posts'
// With path parameters
const postPath = client.api.posts[':id'].$path({
param: { id: '123' },
})
// => '/api/posts/123'
// With query parameters
const searchPath = client.api.posts.$path({
query: { filter: 'test' },
})
// => '/api/posts?filter=test'Unlike $url() which returns a URL object, $path() returns a plain path string, making it convenient for use with routers or as cache keys.
Thanks @ShaMan123!
ApplyGlobalResponse Type Helper for RPC Client
The new ApplyGlobalResponse type helper allows you to add global error response types to all routes in the RPC client. This is useful for typing common error responses from app.onError() or global middlewares:
const app = new Hono()
.get('/api/users', (c) => c.json({ users: ['alice', 'bob'] }, 200))
.onError((err, c) => c.json({ error: err.message }, 500))
type AppWithErrors = ApplyGlobalResponse<
typeof app,
{
401: { json: { error: string; message: string } }
500: { json: { error: string; message: string } }
}
>
const client = hc<AppWithErrors>('http://api.example.com')
// Now client knows about both success and error responses
const res = await client.api.users.$get()
// InferResponseType includes { users: string[] } | { error: string; message: string }Thanks @mohankumarelec!
SSG Redirect Plugin
A new redirectPlugin for SSG generates static HTML redirect pages for HTTP redirect responses (301, 302, 303, 307, 308):
import { toSSG } from 'hono/ssg'
import { defaultPlugin, redirectPlugin } from 'hono/ssg'
const app = new Hono()
app.get('/old', (c) => c.redirect('/new'))
app.get('/new', (c) => c.html('New Page'))
// redirectPlugin must be placed before defaultPlugin
await toSSG(app, fs, {
plugins: [redirectPlugin(), defaultPlugin()],
})The generated redirect pages include a <meta http-equiv="refresh"> tag, a canonical link, and a robots noindex meta tag.
Thanks @3w36zj6!
onAuthSuccess Callback for Basic Auth
The Basic Auth middleware now supports an onAuthSuccess callback that is invoked after successful authentication. This allows you to set context variables or perform logging without re-parsing the Authorization header:
app.use(
'/auth/*',
basicAuth({
username: 'hono',
password: 'ahotproject',
onAuthSuccess: (c, username) => {
c.set('user', { name: username, role: 'admin' })
console.log(`User ${username} authenticated`)
},
})
)The callback also works with async functions and the verifyUser mode.
Thanks @AprilNEA!
getConnInfo for AWS Lambda, Cloudflare Pages, and Netlify
getConnInfo() is now available for three additional adapters:
// AWS Lambda (supports API Gateway v1, v2, and ALB)
import { handle, getConnInfo } from 'hono/aws-lambda'
// Cloudflare Pages
import { handle, getConnInfo } from 'hono/cloudflare-pages'
// Netlify
import { handle, getConnInfo } from 'hono/netlify'
app.get('/', (c) => {
const info = getConnInfo(c)
return c.text(`Your IP: ${info.remote.address}`)
})Thanks @rokasta12!
alwaysRedirect Option for Trailing Slash Middleware
The trailing slash middleware now supports an alwaysRedirect option. When enabled, the middleware redirects before executing handlers, which fixes the issue where trailing slash handling doesn't work with wildcard routes:
app.use(trimTrailingSlash({ alwaysRedirect: true }))
app.get('/my-path/*', async (c) => {
return c.text('wildcard')
})
// /my-path/something/ will be redirected to /my-path/something
// before the wildcard handler is executedProgressive Locale Code Truncation
The normalizeLanguage function in the language middleware now supports RFC 4647 Lookup-based progressive truncation. Locale codes like ja-JP will match ja when only the base language is in supportedLanguages:
app.use(
'/*',
languageDetector({
supportedLanguages: ['en', 'ja'],
fallbackLanguage: 'en',
order: ['cookie', 'header'],
})
)
// Accept-Language: ja-JP → matches 'ja'
// Accept-Language: ko-KR → falls back to 'en'Thanks @sorafujitani!
exports Field for ExecutionContext
The ExecutionContext type now includes an exports property for Cloudflare Workers. You can use module augmentation to type it with Wrangler's generated types:
import 'hono'
declare module 'hono' {
interface ExecutionContext {
readonly exports: Cloudflare.Exports
}
}Thanks @toreis-up!
Performance Improvements
TrieRouter 1.5x ~ 2.0x Faster
The TrieRouter has been significantly optimized with reduced spread syntax usage, O(1) hasChildren checks, lazy regular expression generation, and removal of redundant processes:
| Route | Node.js | Deno | Bun |
|---|---|---|---|
short static GET /user | 1.70x | 1.40x | 1.34x |
dynamic GET /user/lookup/username/hey | 1.38x | 1.69x | 1.51x |
wildcard GET /static/index.html | 1.51x | 1.72x | 1.43x |
| all together | 1.58x | 1.60x | 1.82x |
Thanks @EdamAme-x!
Fast Path for c.json()
c.json() now has the same fast path optimization as c.text(). When no custom status, headers, or finalized state exists, the Response is created directly without allocating a Headers object:
// This common pattern is now faster
return c.json({ message: 'Hello' })Benchmark results:
| Metric | Before | After | Change |
|---|---|---|---|
| Reqs/sec | 92,268 | 95,244 | +3.2% |
| Latency | 5.42ms | 5.25ms | -3.1% |
| Throughput | 17.24MB/s | 19.07MB/s | +10.6% |
Thanks @mgcrea!
New features
client: Add
ApplyGlobalResponsetype helper for RPC Client #4556ssg: Add redirect plugin #4599
client: $path #4636
basic-auth: Add context key and callback options #4645
adapter: Add getConnInfo for AWS Lambda, Cloudflare Pages, and Netlify #4649
trailing-slash: Add
alwaysRedirectoption to support wildcard routes #4658language: Add progressive locale code truncation to normalizeLanguage #4717
types: Add exports field to ExecutionContext #4719
Performance
context: Add fast path to c.json() matching c.text() optimization #4707
trie-router: Improve performance (1.5x ~ 2.0x) #4724
context: Use
createResponseInstancefor new Response #4733
All changes
jsx/dom: Handle empty arrays in render children loop
jsx/dom: Flatten children once at the start to avoid repeated flattening
client: Skip undefined values in form data serialization
client: Add
ApplyGlobalResponsetype helper for RPC Clientssg: Add redirect plugin
client: $path
basic-auth: Add context key and callback options
adapter: Add getConnInfo for AWS Lambda, Cloudflare Pages, and Netlify
trailing-slash: Add
alwaysRedirectoption to support wildcard routescontext: Add fast path to c.json() matching c.text() optimization
language: Add progressive locale code truncation to normalizeLanguage
types: Add exports field to ExecutionContext
trie-router: Improve performance (1.5x ~ 2.0x)
context: Use
createResponseInstancefor new ResponseNext
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.