使用 Hono 和 Bun 构建 HTTP 服务器
Hono 是一个为边缘环境设计的轻量级 Web 框架。
import { Hono } from "hono";
const app = new Hono();
app.get("/", c => c.text("Hono!"));
export default app;
使用 create-hono 从 Hono 的项目模板开始。提示选择模板时请选择 bun。
terminal
bun create hono myapp
Text
create-hono version 0.19.4
✔ Using target directory … myapp
✔ Which template do you want to use? bun
✔ Do you want to install project dependencies? Yes
✔ Which package manager do you want to use? bun
✔ Cloning the template
✔ Installing project dependencies
🎉 Copied project files
Get started with: cd myapp
terminal
cd myapp
bun install
然后启动开发服务器并访问 localhost:3000。
terminal
bun run dev
请参阅 Hono 的使用 Bun 快速开始指南。