> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 Elysia 和 Bun 构建 HTTP 服务器

[Elysia](https://elysiajs.com) 是一个以 Bun 为核心、性能优先的 Web 框架，充分利用了 Bun 的 HTTP、文件系统和热重载 API。通过 `bun create` 快速开始。

```bash terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun create elysia myapp
cd myapp
bun run dev
```

***

要定义一个 HTTP 路由并使用 Elysia 启动服务器：

```ts server.ts icon="https://mintcdn.com/bun-zhcndoc/cnUTwgMuf4cCrwC-/icons/typescript.svg?fit=max&auto=format&n=cnUTwgMuf4cCrwC-&q=85&s=e7767043c9e885c34f2d6c8fe2a95217" theme={"theme":{"light":"github-light","dark":"dracula"}}
import { Elysia } from "elysia";

const app = new Elysia().get("/", () => "Hello Elysia").listen(8080);

console.log(`🦊 Elysia 正在运行，端口号为 ${app.server?.port}...`);
```

***

Elysia 是一个功能齐全的服务器框架，拥有类似 Express 的语法、类型推断、中间件、文件上传，以及用于 JWT 认证、tRPC 等的插件。它还是 [最快的 Bun Web 框架之一](https://github.com/SaltyAom/bun-http-framework-benchmark)。

更多信息请参考 Elysia 的[文档](https://elysiajs.com/quick-start.html)。
