Release Notes
Hono v4.10.0 is now available!
This release brings improved TypeScript support and new utilities.
The main highlight is the enhanced middleware type definitions that solve a long-standing issue with type safety for RPC clients.
Middleware Type Improvements
Imagine the following app:
import { Hono } from 'hono'
const app = new Hono()
const routes = app.get(
'/',
(c) => {
return c.json({ errorMessage: 'Error!' }, 500)
},
(c) => {
return c.json({ message: 'Success!' }, 200)
}
)
The client with RPC:
import { hc } from 'hono/client'
const client = hc<typeof routes>('/')
const res = await client.index.$get()
if (res.status === 500) {
}
if (res.status === 200) {
}
Previously, it couldn't infer the responses from middleware, so a type error was thrown.

Now the responses are correctly typed.

This was a long-standing issue and we were thinking it was super difficult to resolve it. But now come true.
Thank you for the great work @slawekkolodziej!
cloneRawRequest Utility
The new cloneRawRequest
utility allows you to clone the raw Request object after it has been consumed by validators or middleware.
import { cloneRawRequest } from 'hono/request'
app.post('/api', async (c) => {
const body = await c.req.json()
// Clone the consumed request
const clonedRequest = cloneRawRequest(c.req)
await externalLibrary.process(clonedRequest)
})
Thanks @kamaal111!
New features
- feat(types): passing middleware types #4393
- feat(ssg): add default plugin that defines the recommended behavior #4394
- feat(request): add cloneRawRequest utility for request cloning #4382
All changes
- feat(types): passing middleware types by @slawekkolodziej in #4393
- feat(ssg): add default plugin that defines the recommended behavior by @3w36zj6 in #4394
- feat(request): add cloneRawRequest utility for request cloning by @kamaal111 in #4382
- fix(proxy): Correct hop-by-hop header handling per RFC 9110 by @sugar-cat7 in #4459
New Contributors
- @slawekkolodziej made their first contribution in #4393
- @kamaal111 made their first contribution in #4382
Full Changelog: v4.9.12...v4.10.0