Hono #

Hono - [炎] means flame🔥 in Japanese - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, Lagon, and others. Fast, but not only fast.

import { Hono } from 'hono'
const app = new Hono()

app.get('/', (c) => c.text('Hono!!'))

export default app

Features #

  • Ultrafast - The routers are really smart. Not using linear loops. The fastest one will be selected from three routers.
  • Zero-dependencies - Using only Web Standard API. Does not depend on other npm or Deno libraries.
  • Middleware - Hono has built-in middleware, custom middleware, and third-party middleware. Batteries included.
  • TypeScript - First-class TypeScript support. Now, we’ve got “Types”.
  • Multi-runtime - Works on Cloudflare Workers, Fastly [email protected], Deno, Bun, Lagon, or Node.js. The same code runs on all platforms.

Benchmarks #

Cloudflare Workers #

Hono is fastest, compared to other routers for Cloudflare Workers.

Hono x 616,464 ops/sec ±4.76% (83 runs sampled)
itty-router x 203,074 ops/sec ±3.66% (88 runs sampled)
sunder x 314,306 ops/sec ±2.28% (87 runs sampled)
worktop x 194,111 ops/sec ±2.78% (81 runs sampled)
Fastest is Hono
✨  Done in 30.77s.

Deno #

  • Machine: Apple MacBook Pro, 32 GiB, M1 Pro, Deno v1.22.0
  • Scripts: benchmarks/deno
  • Method: oha -z 10s -c 50 ''

Hono is fastest, compared to other frameworks for Deno.

Framework Version Results
Hono 2.2.0 Requests/sec: 176976
Fast 4.0.0-beta.1 Requests/sec: 148011
Faster 5.7 Requests/sec: 36332
oak 10.5.1 Requests/sec: 34641
opine 2.2.0 Requests/sec: 21102

Another benchmark result: denosaurs/bench

Bun #

See: SaltyAom/bun-http-framework-benchmark

Why so fast? #

Routers used in Hono are really smart. SmartRouter automatically picks the best router from the following three routers. Users can use the fastest router without having to do anything!

  • TrieRouter - Implemented with Trie tree structure.
  • RegExpRouter - Match the route with using one big Regex made before dispatch.
  • StaticRouter - Optimized for the static routing.

Hono in 1 minute #

A demonstration to create an application for Cloudflare Workers with Hono.


Not only fast #

Hono is fast. But not only fast.

Write Less, do more #

Built-in middleware make "Write Less, do more" in reality. You can use a lot of middleware without writing code from scratch. Below are examples.

To enable logger and Etag middleware with just this code.

import { Hono } from 'hono'
import { etag } from 'hono/etag'
import { logger } from 'hono/logger'

const app = new Hono()
app.use('*', etag(), logger())

And, the routing of Hono is so flexible. It’s easy to construct large web applications.

import { Hono } from 'hono'
import { basicAuth } from 'hono/basic-auth'

const v1 = new Hono()
v1.get('/posts', (c) => {
  return c.text('list posts')
  .post(basicAuth({ username, password }), (c) => {
    return c.text('created!', 201)
  .get('/posts/:id', (c) => {
    const id = c.req.param('id')
    return c.text(`your id is ${id}`)

const app = new Hono()
app.route('/v1', v1)

Web Standard #

Request and Response object used in Hono are extensions of the Web Standard Fetch API. If you are familiar with that, you don’t need to know more than that.

Multi-runtime #

Thanks to the use of the Web Standard API, Hono works on a variety of platforms.

And using a Node.js adaptor, Hono will works on Node.js.

Developer Experience #

Hono provides fine "Developer Experience". Easy access to Request/Response thanks to the Context object. Above all, Hono is written in TypeScript. So, Hono has "Types"!

For example, the named path parameters will be literal types.


And Validator Middleware will add “Types” to validated values.


© Hono developers.
Built with Hugo & Hugo Book Theme - Not Hono :)