Packages

hono

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

Your version

2.2.4

3 Oct 2022Where it was published

2.7.8 is the newest release of 2.x.

In short

1 new5 fixed1 internal

Security

44 advisories affect 2.2.4; 4.13.16 fixes them

39 more

Release note

Summary

Error handling

This release includes a small breaking change:

Prior to this release, if an error occurred in the Handler, it would throw an Error object. In this release, the error response is assigned to c.res without throwing Error.

app.use('*', async (c, next) => {
  await next()
  // c.res is error reponse
})

app.get('/error', () => {
  throw new Error('Test error')
})

Then you can access the original Error object with c.error.

app.use('*', async (c, next) => {
  await next()
  const originalMessage = c.error.message
  //...
})

For more information, See: #576

JSON array path validation

This is a pretty new feature. Support for array paths in JSON Path for use with Validator Middleware.

If there is a JSON request body as follows:

{
    "posts": [
        {
            "title": "Good Morning",
            "tags": ["Bar", true]
        },
        {
            "title": "Good Night",
            "tags": ["Bar", false]
        }
    ]
}

We can validate with the following rules:

app.post(
  '/posts',
  validator((v) => ({
    title: v.json('posts[*].title').asArray().isRequired(),
    secondTag: v.json('posts[*].tags[1]').asArray().asBoolean(),
  })),
  (c) => {
    return c.text('Valid')
  }
)

Bug fixes

And some bug fixes.

What's Changed

  • validator: Add support for JSON array path validation

  • Fix Trie router multiple matching path parameters

  • cache: Export cache middleware for Deno

  • compose: Don't throw Error; set error response into c.res

  • reg-exp-router: Register path for all the methods if method === METHOD_NAME_ALL.

  • validator: Return HTTP 400 on malformed JSON request

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.