hono
4.13.19 · 16 Nov 2026MIT114.5M / weekRepositoryHomepagenpmAtom feed
4.13.19 is the newest release of 4.x.
In short
1 deprecated20 new2 fixed4 changed2 internal
- Deprecated
cloudflare-workers: Deprecate
serveStatic
Security
47 advisories affect 4.3.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 JWK Auth Middleware has JWT algorithm confusion when JWK lacks "alg" (untrusted header.alg fallback)GHSA-3vhc-576x-3qv4 · 13 Jan 2026Fixed in 4.11.4
- HighHono JWT Middleware's JWT Algorithm Confusion via Unsafe Default (HS256) Allows Token Forgery and Auth BypassGHSA-f67f-6cw9-8mq4 · 13 Jan 2026Fixed in 4.11.4
- HighHono Improper Authorization vulnerabilityGHSA-m732-5p4w-x69g · 22 Oct 2025Fixed in 4.10.2
42 more
- ModerateHono: `csrf()` does not check requests sent by hyperlink auditing (`text/ping`)GHSA-46wx-v44x-9hh2 · 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/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: ReDoS in CORS middleware via Access-Control-Request-HeadersGHSA-8j4g-w8fx-2239 · 3 Aug 2026Fixed in 4.12.34
- ModerateHono: Server-Side XSS via JSX Escaping Bypass in cx() UtilityGHSA-w62v-xxxg-mg59 · 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
- ModerateHono vulnerable to XSS through ErrorBoundary component GHSA-9r54-q6cx-xmh5 · 28 Jan 2026Fixed in 4.11.7
- ModerateHono has an Arbitrary Key Read in Serve static Middleware (Cloudflare Workers Adapter)GHSA-w332-q679-j88p · 27 Jan 2026Fixed in 4.11.7
- ModerateHono cache middleware ignores "Cache-Control: private" leading to Web Cache DeceptionGHSA-6wqw-2p9w-4vw4 · 27 Jan 2026Fixed in 4.11.7
- ModerateHono IPv4 address validation bypass in IP Restriction Middleware allows IP spoofingGHSA-r354-f388-2fhh · 27 Jan 2026Fixed in 4.11.7
- ModerateHono vulnerable to Vary Header Injection leading to potential CORS BypassGHSA-q7jf-gf43-6x6p · 24 Oct 2025Fixed in 4.10.3
- ModerateHono has Body Limit Middleware BypassGHSA-92vj-g62v-jqhh · 12 Sep 2025Fixed in 4.9.7
- ModerateHono allows bypass of CSRF Middleware by a request without Content-Type header.GHSA-2234-fmw7-43wr · 15 Oct 2024Fixed in 4.6.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
- LowHono has improper validation of NumericDate claims (exp, nbf, iat) in JWT verify()GHSA-hm8q-7f3q-5f36 · 9 May 2026Fixed in 4.12.18
- LowHono added timing comparison hardening in basicAuth and bearerAuthGHSA-gq3j-xvxp-8hrf · 19 Feb 2026Fixed in 4.11.10
- LowHono CSRF middleware can be bypassed using crafted Content-Type headerGHSA-rpfr-3m35-5vx5 · 22 Aug 2024Fixed in 4.5.8
Release note
Hono v4.3.0 is now available! Let's take a look at the new features.
Improve the RPC-mode
c.text() is typed
The response of c.text() was just a Response object, not typed.
const routes = app.get('/about/me', (c) => {
return c.text('Me!') // the response is not typed
})With this release, it will be a TypedResponse and you can get the type within the client created by hc.
const client = hc<typeof routes>('http://localhost:8787')
const res = await client.about.me.$get()
const text = await res.text() // text is typed as "Me!"
const json = await res.json() // json is never!Support all JSON primitives
We added the tests for the responses of c.json() to have the correct types and support inferring all primitives. The all tests below are passed!
const app = new Hono()
const route = app
.get('/api/string', (c) => c.json('a-string'))
.get('/api/number', (c) => c.json(37))
.get('/api/boolean', (c) => c.json(true))
.get('/api/generic', (c) => c.json(Math.random() > 0.5 ? Boolean(Math.random()) : Math.random()))
type AppType = typeof route
const client = hc<AppType>('http://localhost')
const stringFetch = await client.api.string.$get()
const stringRes = await stringFetch.json()
const numberFetch = await client.api.number.$get()
const numberRes = await numberFetch.json()
const booleanFetch = await client.api.boolean.$get()
const booleanRes = await booleanFetch.json()
const genericFetch = await client.api.generic.$get()
const genericRes = await genericFetch.json()
type stringVerify = Expect<Equal<'a-string', typeof stringRes>>
expect(stringRes).toBe('a-string')
type numberVerify = Expect<Equal<37, typeof numberRes>>
expect(numberRes).toBe(37)
type booleanVerify = Expect<Equal<true, typeof booleanRes>>
expect(booleanRes).toBe(true)
type genericVerify = Expect<Equal<number | boolean, typeof genericRes>>
expect(typeof genericRes === 'number' || typeof genericRes === 'boolean').toBe(true)
// using .text() on json endpoint should return string
type textTest = Expect<Equal<Promise<string>, ReturnType<typeof genericFetch.text>>>Status code type
If you explicitly specify the status code, such as 200 or 404, in c.json(). It will be added as a type for passing to the client.
// server.ts
const app = new Hono().get(
'/posts',
zValidator(
'query',
z.object({
id: z.string()
})
),
async (c) => {
const { id } = c.req.valid('query')
const post: Post | undefined = await getPost(id)
if (post === undefined) {
return c.json({ error: 'not found' }, 404) // Specify 404
}
return c.json({ post }, 200) // Specify 200
}
)
export type AppType = typeof appYou can get the data by the status code.
// client.ts
const client = hc<AppType>('http://localhost:8787/')
const res = await client.posts.$get({
query: {
id: '123'
}
})
if (res.status === 404) {
const data: { error: string } = await res.json()
console.log(data.error)
}
if (res.ok) {
const data: { post: Post } = await res.json()
console.log(data.post)
}
// { post: Post } | { error: string }
type ResponseType = InferResponseType<typeof client.posts.$get>
// { post: Post }
type ResponseType200 = InferResponseType<typeof client.posts.$get, 200>Improve compatibility with React
The compatibility of hono/jsx/dom has been improved. Now, these React libraries work with hono/jsx/dom!
The below demo is working with hono/jsx/dom, not React.
Google Chrome
If you want to use React libraries with hono/jsx/dom, set-up tsconfig.json and vite.config.ts like the followings:
tsconfig.json:
{
"compilerOptions": {
"paths": {
"react": ["./node_modules/hono/dist/jsx/dom"],
"react-dom": ["./node_modules/hono/dist/jsx/dom"]
}
}
}vite.config.ts:
import { defineConfig } from 'vite'
export default defineConfig({
resolve: {
alias: {
react: 'hono/jsx/dom',
'react-dom': 'hono/jsx/dom'
}
}
})Thanks @usualoma!
createApp() in Factory Helper
createApp() method is added to Factory Helper. If you use this method with createFactory(), you can avoid redundancy in the definition of the Env type.
If your application is like this, you have to set the Env in two places:
import { createMiddleware } from 'hono/factory'
type Env = {
Variables: {
myVar: string
}
}
// 1. Set the `Env` to `new Hono()`
const app = new Hono<Env>()
// 2. Set the `Env` to `createMiddleware()`
const mw = createMiddleware<Env>(async (c, next) => {
await next()
})
app.use(mw)By using createFactory() and createApp(), you can set the Env only in one place.
import { createFactory } from 'hono/factory'
// ...
// Set the `Env` to `createFactory()`
const factory = createFactory<Env>()
const app = factory.createApp()
// factory also has `createMiddleware()`
const mw = factory.createMiddleware(async (c, next) => {
await next()
})Deprecate serveStatic for Cloudflare Workers
serveStatic exported by hono/cloudflare-workers has been deprecated. If you create an application which serves static asset files, use Cloudflare Pages instead.
Other features
Cookie Helper - delete cookie returns the deleted value #2512
Bearer Authenticate - add
headerNameoption #2514JSX/DOM - preserve the state of element even if it is repeatedly evaluated by children #2563
Mimes utility - expose built-in MIME types #2516
Serve Static - expose serve-static builder #2515
Secure Headers - enable to set nonce in CSP #2577
Server-Timing - allow
crossOriginin TimingOptions to be a function #2359Client - add
initoption #2592
All Updates
request: Infer params in a path includes one or more optional parameter
rpc: Add status code to response type
helper/cookie: Delete cookie returns the deleted value
bearer-auth: Add
headerNameoptionjsx/dom: Improve compatibility with React
jsx: Preserve the state of element even if it is repeatedly evaluated by children
Expose built-in MIME types
Expose serve-static builder
secure-headers: Enable to set nonce in CSP
- Deprecated
cloudflare-workers: Deprecate
serveStatic types: Improve response types flow
Improve
ToSchema&WebSocket Helpertypesfactory: Add
createApp()hc: Add
initoptiontiming: Allow crossOrigin in TimingOptions to be a function
Next
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.