> ## 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.

# 热重载 HTTP 服务器

Bun 支持 [`--hot`](/runtime/watch-mode#hot-mode) 标志来启用热重载运行文件。当任何模块或文件发生变化时，Bun 会重新运行该文件。

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun --hot run index.ts
```

***

Bun 会检测你是否正在使用 `Bun.serve()` 运行 HTTP 服务器。当源文件更改时，它会重新加载你的 fetch 处理函数，*而不会* 重启 `bun` 进程。这让热重载几乎是瞬时完成的。

<Note>
  请注意，这并不会刷新你浏览器中的页面。
</Note>

```ts index.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"}}
Bun.serve({
  port: 3000,
  fetch(req) {
    return new Response("Hello world");
  },
});
```
