Packages

hono

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

Your version

2.1.0

27 Aug 2022Where it was published

2.7.8 is the newest release of 2.x.

In short

2 breaking1 new2 changed

Security

44 advisories affect 2.1.0; 4.13.16 fixes them

39 more

Release note

Breaking changes

This release has the breaking changes. Please see the migration guide for more detail:

Summary

  • TrieRouter is 9~10% faster.

  • Enable adding types to c.set/c.get by passing the Generics to new Hono. #472

  • c.req.parseBody parses only FormData. Does not parse JSON, text, or ArrayBuffer. #487

Types for c.set/c.get

Now, we can add the types to the variables used in c.set and c.get. new Hono receive the Generics for the variables and bindings which is for environment variables for Cloudflare Workers.

type Bindings = {
  KV: KVNamespace
  Storage: R2Bucket
}

type WebClient = {
  user: string
  pass: string
}

type Variables = {
  client: WebClient
}

const app = new Hono<{ Variables: Variables; Bindings: Bindings }>()

app.get('/foo', (c) => {
  const client = c.get('client') // client is WebClient
  const kv = c.env.KV // kv is KVNamespace
  //...
})

c.req.parseBody

Now, c.req.parseBody has become only for parsing FormData. We have to parse the request body explicitly.

// `multipart/form` or `application/x-www-form-urlencoded`
const data = await c.req.parseBody()

const jsonData = await c.req.json() // for JSON body
const text = await c.req.text() // for text body
const arrayBuffer = await c.req.arrayBuffer() // for ArrayBuffer

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.