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

# 使用 Remix 和 Bun 构建应用

<Note>
  目前 Remix 开发服务器（`remix dev`）依赖于 Bun 尚未实现的 Node.js API。下面的指南使用 Bun 来初始化项目和安装依赖，但启动开发服务器时会使用 Node.js。
</Note>

***

使用 `create-remix` 初始化一个 Remix 应用。

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun create remix
```

```txt theme={"theme":{"light":"github-light","dark":"dracula"}}
 remix   v1.19.3 💿 让我们构建更好的网站...

   dir   我们应当在哪里创建你的新项目？
         ./my-app

      ◼  使用基础模板 详情见 https://remix.run/docs/en/main/guides/templates#templates
      ✔  模板已复制

   git   是否初始化新的 git 仓库？
         是

  deps   使用 bun 安装依赖？
         是

      ✔  依赖已安装
      ✔  Git 已初始化

  done   完成！
         使用 cd ./my-app 进入项目目录
         查看 README.md 获取开发和部署说明。
```

***

要启动开发服务器，从项目根目录运行 `bun run dev`。这将使用 `remix dev` 命令启动开发服务器。请注意，运行时仍然会使用 Node.js。

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
cd my-app
bun run dev
```

```txt theme={"theme":{"light":"github-light","dark":"dracula"}}
$ remix dev

💿  remix dev

info  building...
info  built (263ms)
Remix App Server started at http://localhost:3000 (http://172.20.0.143:3000)
```

***

打开 [http://localhost:3000](http://localhost:3000) 查看应用。对 `app/routes/_index.tsx` 的任何修改都会在浏览器中热重载。

<Frame>
  ![在本地运行的 Remix 应用](https://github.com/oven-sh/bun/assets/3084745/c26f1059-a5d4-4c0b-9a88-d9902472fd77)
</Frame>

***

要构建并启动你的应用，运行 `bun run build`

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun run build
```

```txt theme={"theme":{"light":"github-light","dark":"dracula"}}
$ remix build
info  building... (NODE_ENV=production)
info  built (158ms)
```

然后在项目根目录运行 `bun run start`。

```sh terminal icon="terminal" theme={"theme":{"light":"github-light","dark":"dracula"}}
bun start
```

```txt theme={"theme":{"light":"github-light","dark":"dracula"}}
$ remix-serve ./build/index.js
[remix-serve] http://localhost:3000 (http://192.168.86.237:3000)
```

***

更多使用 Remix 构建应用的内容，请查阅 [Remix 文档](https://remix.run/)。
