Appearance
Hono
Hono - 在日语中是火焰🔥的意思 - 是一个基于 Web 标准构建的小型、简单且超快的 Web 框架。它适用于任何 JavaScript 运行时:Cloudflare Workers、Fastly Compute、Deno、Bun、Vercel、Netlify、AWS Lambda、Lambda@Edge 和 Node.js。
¥Hono - means flame🔥 in Japanese - is a small, simple, and ultrafast web framework built on Web Standards. It works on any JavaScript runtime: Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Netlify, AWS Lambda, Lambda@Edge, and Node.js.
快速,但不仅仅是快速。
¥Fast, but not only fast.
ts
import { Hono } from 'hono'
const app = new Hono()
app.get('/', (c) => c.text('Hono!'))
export default app快速入门
¥Quick Start
只需运行这个:
¥Just run this:
sh
npm create hono@latestsh
yarn create honosh
pnpm create hono@latestsh
bun create hono@latestsh
deno init --npm hono@latest功能
¥Features
超快 🚀 - 路由
RegExpRouter非常快。不使用线性循环。快速。¥Ultrafast 🚀 - The router
RegExpRouteris really fast. Not using linear loops. Fast.轻量级 🪶 -
hono/tiny预设小于 14kB。Hono 没有任何依赖,仅使用 Web 标准。¥Lightweight 🪶 - The
hono/tinypreset is under 14kB. Hono has zero dependencies and uses only the Web Standards.多运行时 🌍 - 适用于 Cloudflare Workers、Fastly Compute、Deno、Bun、AWS Lambda 或 Node.js。相同的代码在所有平台上运行。
¥Multi-runtime 🌍 - Works on Cloudflare Workers, Fastly Compute, Deno, Bun, AWS Lambda, or Node.js. The same code runs on all platforms.
包含适配 🔋 - Hono 具有内置中间件、自定义中间件、第三方中间件和助手。包含适配。
¥Batteries Included 🔋 - Hono has built-in middleware, custom middleware, third-party middleware, and helpers. Batteries included.
Delightful DX 😃 - 超级干净的 API。一流的 TypeScript 支持。现在,我们得到了 "类型"。
¥Delightful DX 😃 - Super clean APIs. First-class TypeScript support. Now, we've got "Types".
用例
¥Use-cases
Hono 是一个类似于 Express 的简单 Web 应用框架,没有前端。但它在 CDN Edges 上运行,并允许你与中间件结合使用时构建更大的应用。以下是一些用例示例。
¥Hono is a simple web application framework similar to Express, without a frontend. But it runs on CDN Edges and allows you to construct larger applications when combined with middleware. Here are some examples of use-cases.
构建 Web API
¥Building Web APIs
后端服务器的代理
¥Proxy of backend servers
CDN 前端
¥Front of CDN
Edge 应用
¥Edge application
库的基本服务器
¥Base server for a library
全栈应用
¥Full-stack application
谁在使用 Hono?
¥Who is using Hono?
| 项目 | 平台 | 用于什么? |
|---|---|---|
| cdnjs | Cloudflare Workers | 免费开源 CDN 服务。Hono 用于 API 服务器。 |
| Cloudflare D1 | Cloudflare Workers | 无服务器 SQL 数据库。Hono 用于内部 API 服务器。 |
| Cloudflare Workers KV | Cloudflare Workers | 无服务器键值数据库。Hono 用于内部 API 服务器。 |
| BaseAI | 本地 AI 服务器 | 带内存的无服务器 AI 代理管道。一个用于 Web 的开源代理 AI 框架。带有 Hono 的 API 服务器。 |
| Unkey | Cloudflare Workers | 一个开源 API 身份验证和授权。Hono 用于 API 服务器。 |
| OpenStatus | Bun | 一个开源网站和 API 监控平台。Hono 用于 API 服务器。 |
| Deno 基准测试 | Deno | 基于 V8 构建的安全 TypeScript 运行时。Hono 用于基准测试。 |
| Clerk | Cloudflare Workers | 一个开源用户管理平台。Hono 用于 API 服务器。 |
以及以下内容。
¥And the following.
Drivly - Cloudflare Workers
repeat.dev - Cloudflare Workers
你想看更多吗?参见 谁在生产中使用 Hono?。
¥Do you want to see more? See Who is using Hono in production?.
1 分钟内掌握 Hono
¥Hono in 1 minute
使用 Hono 为 Cloudflare Workers 创建应用的演示。
¥A demonstration to create an application for Cloudflare Workers with Hono.

超快
¥Ultrafast
与 Cloudflare Workers 的其他路由相比,Hono 是最快的。
¥Hono is the fastest, compared to other routers for Cloudflare Workers.
Hono x 402,820 ops/sec ±4.78% (80 runs sampled)
itty-router x 212,598 ops/sec ±3.11% (87 runs sampled)
sunder x 297,036 ops/sec ±4.76% (77 runs sampled)
worktop x 197,345 ops/sec ±2.40% (88 runs sampled)
Fastest is Hono
✨ Done in 28.06s.参见 更多基准。
¥See more benchmarks.
轻量级
¥Lightweight
Hono 很小。使用 hono/tiny 预设,其大小在最小化时低于 14KB。有许多中间件和适配器,但它们仅在使用时打包在一起。有关上下文,Express 的大小为 572KB。
¥Hono is so small. With the hono/tiny preset, its size is under 14KB when minified. There are many middleware and adapters, but they are bundled only when used. For context, the size of Express is 572KB.
$ npx wrangler dev --minify ./src/index.ts
⛅️ wrangler 2.20.0
--------------------
⬣ Listening at http://0.0.0.0:8787
- http://127.0.0.1:8787
- http://192.168.128.165:8787
Total Upload: 11.47 KiB / gzip: 4.34 KiB多个路由
¥Multiple routers
Hono 有多个路由。
¥Hono has multiple routers.
RegExpRouter 是 JavaScript 世界中最快的路由。它使用在调度之前创建的单个大型正则表达式来匹配路由。使用 SmartRouter,它支持所有路由模式。
¥RegExpRouter is the fastest router in the JavaScript world. It matches the route using a single large Regex created before dispatch. With SmartRouter, it supports all route patterns.
LinearRouter 可以非常快速地注册路由,因此它适用于每次初始化应用的环境。PatternRouter 只是添加和匹配模式,使其变小。
¥LinearRouter registers the routes very quickly, so it's suitable for an environment that initializes applications every time. PatternRouter simply adds and matches the pattern, making it small.
参见 有关路由的更多信息。
¥See more information about routes.
Web 标准
¥Web Standards
由于使用了 Web 标准,Hono 可以在很多平台上运行。
¥Thanks to the use of the Web Standards, Hono works on a lot of platforms.
Cloudflare Workers
Cloudflare 页面
¥Cloudflare Pages
Fastly 计算
¥Fastly Compute
Deno
Bun
Vercel
AWS Lambda
Lambda@Edge
其他
¥Others
通过使用 Node.js 适配器,Hono 可以在 Node.js 上运行。
¥And by using a Node.js adapter, Hono works on Node.js.
参见 有关 Web 标准的更多信息。
¥See more information about Web Standards.
中间件和助手
¥Middleware & Helpers
Hono 有许多中间件和助手。这使 "写得少,做得多" 成为现实。
¥Hono has many middleware and helpers. This makes "Write Less, do more" a reality.
开箱即用,Hono 提供中间件和助手:
¥Out of the box, Hono provides middleware and helpers for:
其他!
¥Others!
例如,使用 Hono 添加 ETag 和请求日志记录只需要几行代码:
¥For example, adding ETag and request logging only takes a few lines of code with Hono:
ts
import { Hono } from 'hono'
import { etag } from 'hono/etag'
import { logger } from 'hono/logger'
const app = new Hono()
app.use(etag(), logger())参见 有关中间件的更多信息。
¥See more information about Middleware.
开发者体验
¥Developer Experience
Hono 提供了令人愉悦的 "开发者体验"。
¥Hono provides a delightful "Developer Experience".
借助 Context 对象,可以轻松访问请求/响应。此外,Hono 是用 TypeScript 编写的。Hono 有 "类型"。
¥Easy access to Request/Response thanks to the Context object. Moreover, Hono is written in TypeScript. Hono has "Types".
例如,路径参数将是字面量类型。
¥For example, the path parameters will be literal types.

Validator 和 Hono Client hc 启用了 RPC 模式。在 RPC 模式下,你可以使用自己喜欢的验证器(例如 Zod),并轻松地与客户端共享服务器端 API 规范并构建类型安全的应用。
¥And, the Validator and Hono Client hc enable the RPC mode. In RPC mode, you can use your favorite validator such as Zod and easily share server-side API specs with the client and build type-safe applications.
参见 Hono Stacks。
¥See Hono Stacks.