Hono, "Ultrafast" Web Framework for the Edge

Houssem Eddine-Zerrad

Houssem Eddine Zerrad

October 15, 2022

Hono Logo

What is Hono

Hono is advertised as an ultrafast web framework that can be deployed on the edge and all major JavaScript environments. Hono developers say on their official page that:
Hono - [炎] means flame🔥 in Japanese - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, and others.

Hono Features

Hono gives developers 5 features that would help make web development simple and effective while ensuring high-performance standards:

  • Hono is ultrafast thanks to its smart routing technique which automatically chooses the best routing algorithm upon request.
  • Hono has zero dependencies as it uses the Web Standard API for networking and HTTP protocol communications.
  • Hono has built-in middleware for repetitive tasks such as authentication, CORS, cache, compression, GraphQL server, and many more.
  • Hono has first-class TypeScript support for an improved developer experience.
  • Hono is executable on multiple JavaScript platforms with the same codebase.

Development in Hono

Hono's API seems quite similar to the widely known Express.js. However, route callbacks receive a Context object that performs actions both on request and response data.
To run Hono on Bun.js:
bun add hono
Then create index.ts with the following code:
import { Hono } from 'hono' const app = new Hono(); app.get('/', (c) => c.text('Hello from Hono!'))

and run:

bun ./index.ts
Running Hono on Node.js requires an extra dependency, @honojs/node-server which serves as an adapter to serve the application.

To run Hono on Node.js:

npm i --save hono @honojs/node-server typescript # or yarn add hono @honojs/node-server typescript
Then create index.ts with the following code:
import { serve } from '@honojs/node-server' import { Hono } from 'hono' const app = new Hono(); app.get('/', (c) => c.text('Hello from Hono!')) serve(app)
and run it either by compiling index.ts :
npx tsc . node ./index.js
or using ts-node:
## install ts-node npm i ts-node --save-dev # or yarn add -D ts-node ## run the server ts-node ./index.ts

Hono Benchmarks

According to the official benchmarks performed by Hono creators ( Public Source Code ) shows that Hono outperforms the majority of widely-used edge-compatible web frameworks, such as Deno's fast, faster and opine.

On Cloudflare Workers

FrameworkResults
Hono616.464 ops/sec (±4.76%)
Itty-router203.074 ops/sec (±3.66%)
sunder314.306 ops/sec (±2.28%)
worktop194.111 ops/sec (±2.78%)
source: Hono official website

On Deno

Source Code: benchmarks/deno
FrameworkVersionResults
Hono2.2.0176976 req/sec
Fast4.0.0-beta.1148011 req/sec
Faster5.736332 req/sec
Oak10.5.134641 req/sec
Opine2.2.021102 req/sec
source: Hono official website

On Bun

FrameworkGet (/)Params, query & headerPost JSON
baojs89,815.61 req/sec78,893.78 req/sec73,613.71 req/sec
bun-bakery112,590.01 req/sec79,890.18 req/sec69,406.26 req/sec
bun163,705.35 req/sec129,364.36 req/sec89,723.65 req/sec
colston7,716.77 req/sec103,185.97 req/sec11,604.82 req/sec
express24,538.77 req/sec23,865.71 req/sec6,491.6 req/sec
hono186,835.8 req/sec138,642.78 req/sec93,240.68 req/sec
hyperbun97,856.71 req/sec74,648.01 req/sec68,810.79 req/sec
kingworld158,395.62 req/sec129,790.04 req/sec89,371.59 req/sec
nbit87,300.5 req/sec73,024.87 req/sec68,067.32 req/sec
source: SaltyAom's benchmark repository

Conclusion

Hono is a promising web framework for the edge that provides decent performance, without sacrificing developer experience. It has an API that is similar to the widely-adopted express.js with middlewares that cover most of the typical use cases like authentication and validation.

Whether Hono will be the de-facto framework for edge web server is debatable. However, given its performance and ease of use, it is possible that Hono will stand firm and have a good share of deployments in edge environments, especially for Cloudflare Workers.

Tags

Node.js
JavaScript
Web Frameworks
Edge Computing

About the Author

Houssem Eddine Zerrad's profile picture

Houssem Eddine Zerrad

Joined April 30, 2022

Senior Software Engineer | Cloud Architect | Gamer at Heart

email

Join the Newsletter!

Get the latest and trending sniffs in the software industry, straight to your inbox.

This site is protected by reCAPTCHA , and the Google Privacy Policy and Terms of Service apply

Read Also

Blog owned by Houssem Eddine Zerrad. Posts and comments are owned by the poster

Copyright © 2023 DevDog - All Rights Reserved