hono
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHono
Hono
Hono (Japanese for "Flame") is a small, simple, and ultrafast web framework built on Web Standards. It runs anywhere: Cloudflare Workers, Fastly, Deno, Bun, Node.js, and Vercel.
Hono(日语意为“火焰”)是一款基于Web标准构建的轻量、简洁且超快速的Web框架。它可在任意环境运行:Cloudflare Workers、Fastly、Deno、Bun、Node.js以及Vercel。
When to Use
适用场景
- Edge Computing: Explicitly designed for Cloudflare Workers / Edge runtimes.
- Performance: Uses , making it significantly faster than Express.
RegExpRouter - Single File API: Perfect for small microservices or proxy servers.
- 边缘计算:专为Cloudflare Workers / 边缘运行时设计。
- 性能优势:采用,速度显著快于Express。
RegExpRouter - 单文件API:非常适合小型微服务或代理服务器。
Quick Start
快速开始
typescript
import { Hono } from "hono";
const app = new Hono();
app.get("/", (c) => c.text("Hello Hono!"));
app.get("/user/:name", (c) => {
const name = c.req.param("name");
return c.json({ message: `Hello ${name}!` });
});
export default app;typescript
import { Hono } from "hono";
const app = new Hono();
app.get("/", (c) => c.text("Hello Hono!"));
app.get("/user/:name", (c) => {
const name = c.req.param("name");
return c.json({ message: `Hello ${name}!` });
});
export default app;Core Concepts
核心概念
Web Standards
Web标准
Hono uses standard and objects. No proprietary API wrapper.
RequestResponseHono使用标准的和对象,无专有API封装。
RequestResponseMiddleware
中间件
Similar to Express but . Batteries included: CORS, JWT, Basic Auth, Cache.
await next()与Express类似,但需使用。内置多种实用功能:CORS、JWT、基础认证(Basic Auth)、缓存(Cache)。
await next()RPC (Hono RPC)
RPC(Hono RPC)
Share types between client and server for end-to-end type safety without GraphQL.
无需GraphQL,即可在客户端与服务器之间共享类型,实现端到端的类型安全。
Best Practices (2025)
2025年最佳实践
Do:
- Use Hono RPC: If you control both client and server, the typed client is amazing.
- Run on Bun: Hono + Bun is currently one of the fastest combinations for JS backends.
Don't:
- Don't use heavy Node.js dependencies: If targeting Cloudflare Workers, avoid packages that rely on or native Node modules.
fs
建议:
- 使用Hono RPC:若你同时控制客户端和服务器,类型化客户端的体验极佳。
- 在Bun上运行:目前Hono + Bun是JS后端最快的组合之一。
避免:
- 不要使用重型Node.js依赖:若目标环境为Cloudflare Workers,避免依赖或Node.js原生模块的包。
fs