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

# 使用 Astro 和 Bun 构建应用

使用 `bun create astro` 初始化一个全新的 Astro 应用。`create-astro` 包会检测到你正在使用 `bunx`，并使用 `bun` 安装依赖。

```sh terminal icon="terminal" theme={null}
bun create astro
```

```txt theme={null}
╭─────╮  Houston：
│ ◠ ◡ ◠  我们很高兴有你加入。
╰─────╯

 astro   v3.1.4 启动序列已初始化。

   dir   我们应该在哪里创建你的新项目？
         ./fumbling-field

  tmpl   你想如何开始你的新项目？
         使用博客模板
      ✔  模板已复制

  deps   是否安装依赖？
         是
      ✔  依赖已安装

    ts   你是否打算编写 TypeScript？
         是

   use   TypeScript 的严格程度？
         严格
      ✔  TypeScript 已自定义

   git   是否初始化一个新的 git 仓库？
         是
      ✔  Git 已初始化

  next   确认升空。探索你的项目！

         使用 cd ./fumbling-field 进入项目目录
         运行 `bun run dev` 启动开发服务器。按 CTRL+C 停止。
         使用 astro add 添加像 react 或 tailwind 这样的框架。

         卡住了？加入我们 https://astro.build/chat

╭─────╮  Houston：
│ ◠ ◡ ◠  祝你好运，宇航员！🚀
╰─────╯
```

***

使用 `bunx` 启动开发服务器。

默认情况下，Bun 使用 Node.js 运行开发服务器。要改用 Bun 运行时，请传递 `--bun` 标志。

```sh terminal icon="terminal" theme={null}
bunx --bun astro dev
```

```txt theme={null}
  🚀  astro  v3.1.4 在 200 毫秒内启动

  ┃ 本地    http://localhost:4321/
  ┃ 网络    使用 --host 暴露
```

***

在浏览器中打开 [http://localhost:4321](http://localhost:4321) 查看结果。Astro 会在你编辑源文件时热重载应用。

<Frame>
  <img src="https://i.imgur.com/Dswiu6w.png" caption="一个在 Bun 上运行的 Astro v3 入门应用" />
</Frame>

***

参见 [Astro 文档](https://docs.astro.build/en/getting-started/)。
