Packages

hono

4.13.19 · 16 Nov 2026MIT114.5M / weekRepositoryHomepagenpmAtom feed

Your version

4.1.0

11 Mar 2024Where it was published

4.13.19 is the newest release of 4.x.

In short

14 new2 fixed1 changed2 internal

Security

47 advisories affect 4.1.0; 4.13.16 fixes them

42 more

Release note

Hono v4.1.0 is now available! Let's take a look at the new features.

WebSocket Helper

Now Hono supports WebSockets! With WebSocket helper, you can easily handle WebSockets in your application. Currently, Cloudflare Workers / Pages, Deno, and Bun adapters are available.

const app = new Hono()

app.get(
  '/ws',
  upgradeWebSocket((c) => {
    return {
      onMessage(event, ws) {
        console.log(`Message from client: ${event.data}`)
        ws.send('Hello from server!')
      },
      onClose: () => {
        console.log('Connection closed')
      }
    }
  })
)

PRC mode is now also supported for WebSockets endpoints. The following is a demo.

WebSocket Helper

Thanks @nakasyou!

Body Limit Middleware

Introducing Body Limit Middleware. This middleware can limit the file size of the request body.

const app = new Hono()

app.post(
  '/upload',
  bodyLimit({
    maxSize: 50 * 1024, // 50kb
    onError: (c) => {
      return c.text('overflow :(', 413)
    }
  }),
  async (c) => {
    const body = await c.req.parseBody()
    if (body['file'] instanceof File) {
      console.log(`Got file sized: ${body['file'].size}`)
    }
    return c.text('pass :)')
  }
)

Thanks @EdamAme-x and @usualoma!

ES2022

We made the target in the tsconfig.json as ES2022 instead of ES2020. So, the generated JavaScript files are now ES2022. That made the file size smaller! The following is the result of the minify and build of "Hello World" with Wrangler.

// ES2020
hono => Total Upload: 20.15 KiB / gzip: 7.42 KiB
hono/tiny => Total Upload: 12.74 KiB / gzip: 4.69 KiB
// ES2022
hono => Total Upload: 18.46 KiB / gzip: 7.09 KiB
hono/tiny => Total Upload: 11.12 KiB / gzip: 4.38 KiB

Performance has also been improved in some Node.js environments.

SS

Other features

  • Cookie Helper - Supports __Secure- and __Host- prefix #2269

  • Cookie Helper - Check bis condition #2314

  • jsx/dom - Add more React staff #2197

  • SSG - Generate files concurrently #2187

  • HTTP Exception - Add cause option #2224

  • Logger - Support NO_COLOR #2228

All Updates

  • Add a "cause" option to HTTPException

  • logger: Support NO_COLOR

  • cookie: Add secure and host prefix support

  • ssg: Generate files concurrently

  • jsx: More react staff

  • Introduce Body Limit Middleware using stream

  • Introduce WebSocket Helper / Adapter

  • body-limit: Export bodyLimit for Deno

  • websocket: Export WebSocket helper for Deno

  • cookie: Add Cookie bis condition check

  • 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.