Packages

hono

4.13.19 · 16 Nov 2026MIT112.7M / weekRepositoryHomepagenpmAtom feed

Your version

1.4.0

26 May 2022Where it was published

1.6.4 is the newest release of 1.x.

In short

1 breaking2 new3 fixed1 changed1 internal

  • Breaking

    This release includes some breaking changes.

Security

44 advisories affect 1.4.0; 4.13.16 fixes them

39 more

Release note

Breaking changes!!

This release includes some breaking changes.

Only one handler will be processed

Before this release, it is possible multiple handlers will be dispatched.

app.get('/a', async c => {
    console.log('a')
    return c.text('a')
});
app.get('/:slug', async c => {
    console.log('slug')
    return c.text('slug')
})

Output is a, slug.

But from this release, only one handler will be dispatched.

app.get('/book/a', (c) => c.text('a')) // a
app.get('/book/:slug', (c) => c.text('common')) // common
GET /book/a ---> `a` // common will not be dispatched
GET /book/b ---> `common` // a will not be dispatched

Stop proceeding when the handler is dispatched

If you write middleware like these, please rewrite routing.

app.get('/api', (c) => {
  return c.text('foo')
}) // <--- stop process

app.use('/api/*', middleware()) // <--- not dispached!!

Rewrite to

app.use('/api/*', middleware()) // <--- dispached!!

app.get('/api', (c) => {
  return c.text('foo')
})

Routing Priority

Routing priority is fixed. Decided by the order of registration.

app.get('/api/*', 'c') // score 1.1 <--- `/*` is special wildcard
app.get('/api/:type/:id', 'd') // score 3.2
app.get('/api/posts/:id', 'e') // score 3.3
app.get('/api/posts/123', 'f') // score 3.4
app.get('/*/*/:id', 'g') // score 3.5
app.get('/api/posts/*/comment', 'h') // score 4.6 - not match
app.get('*', 'a') // score 0.7
app.get('*', 'b') // score 0.8
GET /api/posts/123
---> will match => c, d, e, f, b, a, b
---> sort by score => a, b, c, d, e, f, g

router option

routerClass option is obsolete. Use router option instead.

import { RegExpRouter } from 'hono/router/reg-exp-router'
const app = new Hono({ router: new RegExpRouter() })

What's Changed

  • context: Initialize status and header values after newResponse

  • jwt: Ensure the request does not continue if the jwt token is invalid or expired

  • Adoption of a new sort order for routing in RegExpRouter

  • feat(trie-router) : Routing with order specification

  • router: Fixed trie-router bugs

  • c.res is available before dispatching

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.