Packages

hono

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

Your version

3.0.0

major18 Feb 2023Where it was published

3.12.12 is the newest release of 3.x.

In short

4 breaking1 deprecated17 new3 faster11 fixed17 changed14 internal

  • Breaking

    There are some breaking changes.

  • Breaking

    breaking: Obsolete no args c.req.valid()

  • Breaking

    feat(router) StaticRouter obsolete

  • Breaking

    adapter: Simplify HandleInterface and reduce bundle size

  • Deprecated

    @honojs namespace in the Npm registry is deprecated, but we can use @hono!

Security

44 advisories affect 3.0.0; 4.13.16 fixes them

39 more

Release note

Do Everything, Run Anywhere, But Small, And Faster.

Hono v3.0.0 has been released now! Introduce the new features.

Note

There are some breaking changes. See the migration guide.

HonoRequest

Previously, c.req was an extended Request object. But, the functions and types vary by runtime. So it was causing inconvenience.
Hence, HonoRequest is born.

HonoRequest has Hono-specific functions such as req.param() and req.query, then will wrap the Request object. You can access the original Response object via req.raw. Most functions and properties are bypassed, so you can still use c.req as before.

// c.req is HonoRequest
const id = c.req.param('id')
const query = c.req.query('q')
const data = await c.req.json()

// originalRequest is Request
const originalRequest = c.req.raw

Performance improvement

It is getting 2% - 11% faster. So, Hono is fast.

RegExpRouter becomes the fastest router

RegExpRouter become the fastest router in the JavaScript world which includes such "find-my-way" used in Fastify.

You can find the benchmark scripts.

Good-bye StaticRouter

Thanks to the faster RegExpRouter, StaticRouter is no longer needed. Obsolete. Good-bye StaticRouter!

New Validator

The previous Validator Middleware is obsolete and you can use the new validator. Its validator is very thin and we recommend using it with a third-party validator.

If you want to use Zod, now, we have "Zod Validator Middleware".

import { zValidator } from '@hono/zod-validator'
import { Hono } from 'hono'
import { z } from 'zod'

const app = new Hono()

app.post(
  '/posts',
  zValidator(
    'json',
    z.object({
      id: z.number(),
      title: z.string(),
    })
  ),
  (c) => {
    const { id, title } = c.req.valid('json')
    return c.text(`${id} is ${title}!`)
  }
)

RPC

Then, we'll show you the magic.


user-images.githubusercontent.com/10682/2194106…


We've made the HTTP client which is called hc. API specs can be shared as types between the API server and the client. It is like tRPC, but easier to handle due to its being integrated.

To enable RPC mode, simply change json() to jsonT() and share the endpoint type.

// server.ts
const route = app.post(
  '/posts',
  zValidator(
    'json',
    z.object({
      id: z.number(),
      title: z.string(),
    })
  ),
  (c) => {
    const { id, title } = c.req.valid('json')
    // ...
    return c.jsonT(
      {
        success: true,
        message: 'created!',
      },
      201
    )
  }
)

export type AppType = typeof route

On the client side, import the type and pass it to hc() as a generics.

import { hc } from 'hono/client'
import type { AppType } from './index'

const client = hc<AppType>('/api')

Now it is ready for use. See it.

SC

Adapter

Hono is also suitable for running in functions of Cloudflare Pages or in Edge Functions of Next.js. To make them easier, you can use the "Adapter".

// pages/api/[...route].ts
import { Hono } from 'hono'
import { handle } from 'hono/nextjs'

export const config = {
  runtime: 'edge',
}

const app = new Hono()

app.get('/hello', (c) => {
  return c.json({
    message: 'Hello from Hono!',
  })
})

export default handle(app, '/api')

The combination of this adapter and RPC is powerful. You can write the REST API on the Edge Functions and write the React applications with hc.

Also, ServeStatic Middleware has been obsolete and the feature of serving static files is now provided via an Adapter.

import { Hono } from 'hono'
import { serveStatic } from 'hono/cloudflare-workers'

const app = new Hono()

app.get('/static/*', serveStatic({ root: './' }))
app.get('/favicon.ico', serveStatic({ path: './favicon.ico' }))

HTTPException

The new HTTPException makes your application safer.

Multi-runtime CI support

Hono works on most JavaScript runtimes. It becomes to be tested on the CI for the following five runtimes.

Support WinterCG Runtime Keys

Hono is following WinterCG and will be "de fact standard for Web Standard". Now, c.runtime() supports WinterCG's Runtime Keys.

app.get('/', (c) => {
  if (c.runtime === 'workerd') {
    return c.text('You are on Cloduflare')
  } else if (c.runtime === 'bun') {
    return c.text('You are on Bun')
  }
  ...
})

Available runtime keys are below.

  • node

  • deno

  • bun

  • workerd - Cloudflare Workers

  • fastly

  • edge-light - Vercel Edge Functions

  • lagon

  • other

create-hono

You can create the Hono application with one command and launch the application in 30 seconds!

npm create hono@latest my-app

SS

@honojs to @hono

@honojs namespace in the Npm registry is deprecated, but we can use @hono! So each Middleware is now renamed as follows.

And Node.js adapter becomes @hono/node-server.

New middleware

Adding them, we can use these new middleware.

New website

Finally, we have to tell you about it. We have the new website with an ultra cool domain name.

hono.dev!!

Not only the domain but has been changed from Hugo-based to VitePress-based, making it easier to contribute.

Wrap-up

Many new features. Enjoy and share!

All Changes

  • request: Make optional param type correct

  • Use substring and //.test ...

  • bun: Fixed throwing the error in HTTPException

  • validator: Support multiple handlers w/ complex patterns.

  • req: Support c.req.valid('query')

  • context: Set the header values of already set

  • context: Fixed bug raw Response content-type is overwritten

  • Missing mime types

  • cloudflare-pages: Fix type incompatibility

  • reg-exp-router: Lookup static path by using Object

  • Rename runtime keys

  • Rewnew output types

  • Breaking

    breaking: Obsolete no args c.req.valid()

  • req: never if c.req.valid()

  • context: Improve handling response

  • Fix 404 error on Serve Static Middleware

  • serve-static: Decode url pathname

  • reg-exp-router: Cache Result<T> instead of T if there is no parameter.

  • hc - Hono Client

  • Use added app's errorHandler

  • Revert "feat: use added app's errorHandler (#871)"

  • Remove the StaticRouter from default candidates.

  • Breaking

    feat(router) StaticRouter obsolete

  • Use added app's errorHandler with comose()

  • Merge main into next

  • adapter: handle(path, app) for CF Pages & Next.js

  • validator: Moved validator outside of middleware

  • Breaking

    adapter: Simplify HandleInterface and reduce bundle size

  • app: Support multiple methods with app.on()

  • Move http-exception out of utils

  • deno: Allow {} for app.fetch fo compatibility

  • Header may return undefined

  • req: Query return type as string | undefined

  • Change the arg InferResponseType receives

  • client: Introduce Fetch type

  • jsx: Declare types for JSX correctly

  • v3

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.