Hono is a lightweight web framework that executes on edge environments and major JavaScript runtimes. It supports TypeScript, relies on no external dependency, and employs a "smart routing" technique that promises "ultrafast" performance on all platforms.
Hono - [炎] means flame🔥 in Japanese - is a small, simple, and ultrafast web framework for Cloudflare Workers, Deno, Bun, and others.
Hono gives developers 5 features that would help make web development simple and effective while ensuring high-performance standards:
Context
object that performs actions both on request and response data.bun add hono
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
@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
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)
index.ts
:npx tsc . node ./index.js
ts-node
:## install ts-node npm i ts-node --save-dev # or yarn add -D ts-node ## run the server ts-node ./index.ts
fast
, faster
and opine
.Framework | Results |
---|---|
Hono | 616.464 ops/sec (±4.76%) |
Itty-router | 203.074 ops/sec (±3.66%) |
sunder | 314.306 ops/sec (±2.28%) |
worktop | 194.111 ops/sec (±2.78%) |
Framework | Version | Results |
---|---|---|
Hono | 2.2.0 | 176976 req/sec |
Fast | 4.0.0-beta.1 | 148011 req/sec |
Faster | 5.7 | 36332 req/sec |
Oak | 10.5.1 | 34641 req/sec |
Opine | 2.2.0 | 21102 req/sec |
Framework | Get (/) | Params, query & header | Post JSON |
---|---|---|---|
baojs | 89,815.61 req/sec | 78,893.78 req/sec | 73,613.71 req/sec |
bun-bakery | 112,590.01 req/sec | 79,890.18 req/sec | 69,406.26 req/sec |
bun | 163,705.35 req/sec | 129,364.36 req/sec | 89,723.65 req/sec |
colston | 7,716.77 req/sec | 103,185.97 req/sec | 11,604.82 req/sec |
express | 24,538.77 req/sec | 23,865.71 req/sec | 6,491.6 req/sec |
hono | 186,835.8 req/sec | 138,642.78 req/sec | 93,240.68 req/sec |
hyperbun | 97,856.71 req/sec | 74,648.01 req/sec | 68,810.79 req/sec |
kingworld | 158,395.62 req/sec | 129,790.04 req/sec | 89,371.59 req/sec |
nbit | 87,300.5 req/sec | 73,024.87 req/sec | 68,067.32 req/sec |
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.
Get the latest and trending sniffs in the software industry, straight to your inbox.
Blog owned by Houssem Eddine Zerrad. Posts and comments are owned by the poster
Copyright © 2023 DevDog - All Rights Reserved