> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/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={null}
bun create remix
```

```txt theme={null}
 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`。这会使用 Node.js 运行 `remix dev` 命令。

```sh terminal icon="terminal" theme={null}
cd my-app
bun run dev
```

```txt theme={null}
$ remix dev

💿  remix dev

info  正在构建...
info  已构建 (263ms)
Remix 应用服务器已在 http://localhost:3000 (http://172.20.0.143:3000) 启动
```

***

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

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

***

要构建你的应用，运行 `bun run build`。

```sh terminal icon="terminal" theme={null}
bun run build
```

```txt theme={null}
$ remix build
info  正在构建... (NODE_ENV=production)
info  已构建 (158ms)
```

然后从项目根目录启动应用。

```sh terminal icon="terminal" theme={null}
bun start
```

```txt theme={null}
$ remix-serve ./build/index.js
[remix-serve] http://localhost:3000 (http://192.168.86.237:3000)
```

***

参见 [Remix 文档](https://remix.run/) 了解更多。
