Packages

hono

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

Your version

3.12.0

4 Jan 2024Where it was published

3.12.12 is the newest release of 3.x.

In short

3 security1 deprecated9 new2 fixed1 changed2 internal

  • Security

    This release introduces CSRF Protection Middleware.

  • Security

    CSRF Protection Middleware compares the Origin header value with the request URL.

  • Security

    middleware/csrf: Introduce CSRF middleware

  • Deprecated

    c.stream() is now deprecated and you should use stream() in Streaming Helper.

Security

45 advisories affect 3.12.0; 4.13.16 fixes them

40 more

Release note

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

CSRF Protection Middleware

This release introduces CSRF Protection Middleware. It is easy to use and can prevent CSRF attacks by simply writing like the following:

import { csrf } from 'hono/csrf'

// ...

app.use('*', csrf())

CSRF Protection Middleware compares the Origin header value with the request URL. This is the same method used by SvelteKit and is valid in many situations except when using older browsers.

css Helper

We created a built-in CSS in JS(X). It's "hono/css".

The css helper can be used with JSX. You can write the CSS in a css template literal tag and specify the returned value as the class value and it will be applied to that element.

app.get('/', (c) => {
  const headerClass = css`
    background-color: orange;
    color: white;
    padding: 1rem;
  `
  return c.html(
    <html>
      <head>
        <Style />
      </head>
      <body>
        <h1 class={headerClass}>Hello!</h1>
      </body>
    </html>
  )
})

If you use VS Code, you can use vscode-styled-components for Syntax highlighting and IntelliSense for css tagged literals.

SS

By combining keyframes and JSX rendering, you can create a like button without JavaScript!

Like button

Also, you can use a CSS-generating design tool such as Figma to create components even if you are not a CSS guru.

You can use other CSS in JS libraries in Hono, such as Panda CSS. However, hono/css can be used by simply importing the hono package, and Async components and Suspense are also supported.

stream.onAbort()

c.stream() is now deprecated and you should use stream() in Streaming Helper. And, stream.abort() has been added.

app.get('/stream', (c) => {
  return stream(c, async (stream) => {
    stream.onAbort(() => {
      console.log('Aborted!')
    })
    // ...
  })
})

onNotFound option for serveStatic

Cloudflare Workers, Deno, and Bun serveStatic now have an onNotFound option. You can write a handle when a file is not found.

app.get(
  '/static/*',
  serveStatic({
    onNotFound: (path, c) => {
      console.log(`${path} is not found, you access ${c.req.path}`)
    }
  })
)

colorize option for showRoutes()

The colorize option has been added to the showRoutes function in hono/dev. If you set this value to false, the output will not be colored, which can be used when you want to log output, etc.

import { showRoutes } from 'hono/dev'

showRoutes(app, {
  colorize: false
})

Other new features

  • dev: Add getRouterName()

  • helper: Export SSEStreamingApi and SSEMessage. Thanks to @thanks to @watany-dev!

  • client: Add param option to $url()

All Updates

  • Move c.stream* to helper

  • Security

    middleware/csrf: Introduce CSRF middleware

  • dev: Add getRouterName()

  • Add onNotFound handler in adapters' serveStatic

  • helper: Export SSEStreamingApi and SSEMessage.

  • Pass context to onNotFound callback in serveStatic

  • Introduce css Helper

  • dev: Add colorize option for showRoutes()

  • Implement stream.onAbort

  • client: Add param option to $url()

  • deno: Export css Helper for Deno

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