v4.10.0
honojs/honov4.10.0Oct 16, 2025by yusukebe
AI Summary
Hono v4.10.0 brings significant TypeScript improvements with enhanced middleware type definitions that now correctly infer responses from middleware for RPC clients, solving a long-standing type safety issue. The release also introduces a new `cloneRawRequest` utility for cloning consumed requests and includes a fix for proxy hop-by-hop header handling per RFC 9110.
Key Highlights
- Enhanced middleware type definitions now correctly infer responses for RPC clients, fixing a long-standing TypeScript issue
- New `cloneRawRequest` utility allows cloning consumed Request objects for use with external libraries
- Fixed proxy hop-by-hop header handling to comply with RFC 9110
- Added new SSG default plugin defining recommended behavior
- First contributions from @slawekkolodziej and @kamaal111
New Features
- Middleware type definitions passing middleware types to RPC clients
- SSG default plugin for recommended behavior
- cloneRawRequest utility for request cloning
Full Release Notes
# 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:
```ts
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:
```ts
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.
<img width="1538" height="724" alt="CleanShot 2025-10-17 at 06 51 48@2x" src="https://github.com/user-attachments/assets/7e660db0-6c52-4249-9a3d-2932614bbace" />
Now the responses are correctly typed.
<img width="1586" height="876" alt="CleanShot 2025-10-17 at 06 54 13@2x" src="https://github.com/user-attachments/assets/ef6136f1-bc26-4625-9238-0aec25110efc" />
---
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.
```ts
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 https://github.com/honojs/hono/pull/4393
- feat(ssg): add default plugin that defines the recommended behavior https://github.com/honojs/hono/pull/4394
- feat(request): add cloneRawRequest utility for request cloning https://github.com/honojs/hono/pull/4382
## All changes
- feat(types): passing middleware types by @slawekkolodziej in https://github.com/honojs/hono/pull/4393
- feat(ssg): add default plugin that defines the recommended behavior by @3w36zj6 in https://github.com/honojs/hono/pull/4394
- feat(request): add cloneRawRequest utility for request cloning by @kamaal111 in https://github.com/honojs/hono/pull/4382
- fix(proxy): Correct hop-by-hop header handling per RFC 9110 by @sugar-cat7 in https://github.com/honojs/hono/pull/4459
## New Contributors
- @slawekkolodziej made their first contribution in https://github.com/honojs/hono/pull/4393
- @kamaal111 made their first contribution in https://github.com/honojs/hono/pull/4382
**Full Changelog**: https://github.com/honojs/hono/compare/v4.9.12...v4.10.0