Packages

hono

4.13.19 · 16 Nov 2026MIT113.6M / weekRepositoryHomepagenpmAtom feed

Your version

2.4.0

1 Nov 2022Where it was published

2.7.8 is the newest release of 2.x.

In short

2 new3 fixed3 internal

Security

44 advisories affect 2.4.0; 4.13.16 fixes them

39 more

Release note

Summary

This release includes the fix for the ESM support, v.queries() feature in Validator middleware, and CustomHandler that is exported as Handler interface.

Fixing ESM support

Previously, if we use Hono package in Node.js directly, the error would throw. This release has enabled proper support for both ESM and CommonJS (However, this isn't easy to test and may not work well in your environment. If there is a problem, please let me know. We will fix it).

"Handler" interface

If we want to declare a handler outside of app.get(), we write it like this:

const handler: Handler = (c) => {
  return c.text('Hi!')
}

Then, in this handler, how can we make c.env or c.get('foo') have a type? Pass string as the first argument of the Generics for Handler and write the following:

type Env = {
  Bindings: { TOKEN: string }
  Variables: { post: Post }
}

const handler: Handler<string, Env> = (c) => { // <---
  const post = c.get('post')
  return c.json(post)
}

This is redundant to write string on purpose. So, in this release, we can write just like this:

const handler: Handler<Env> = (c) => {
  const post = c.get('post')
  return c.json(post)
}

Of course, it keeps to have the types:

Actually, we can do something similar for Validator schema:

const schema = (v: Validator) => ({
  query: v.query('q'),
})

type Schema = ReturnType<typeof schema>

const handler: Handler<Schema> = (c) => {
  const { query } = c.req.valid()
  return c.json({ query: query })
}

What's Changed

  • build: Fix ESM support in Node.js / use esbuild

  • validator: Enable handling "Bad Request" in validator

  • types: Introduce CustomHandler interface

  • validator: Support v.queries

  • types: Improve custom handler

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.