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

# 使用 Astro 和 Bun 构建应用

使用 `bun create astro` 初始化一个全新的 Astro 应用。`create-astro` 包会检测你是否使用了 `bunx`，并自动使用 `bun` 安装依赖。

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

```txt theme={"theme":{"light":"github-light","dark":"dracula"}}
╭─────╮  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={"theme":{"light":"github-light","dark":"dracula"}}
bunx --bun astro dev
```

```txt theme={"theme":{"light":"github-light","dark":"dracula"}}
  🚀  astro  v3.1.4 在 200ms 内启动

  ┃ 本地    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/) 获得完整说明。
