Przejdź do głównej zawartości

Use Bun with Astro

Ta treść nie jest jeszcze dostępna w Twoim języku.

Bun is an all-in-one JavaScript runtime & toolkit. See Bun’s documentation for more information.

Create a new Astro project with Bun using the following create-astro command:

Terminal window
bun create astro my-astro-project-using-bun

If you skipped the “Install dependencies?” step during the CLI wizard, then be sure to install your dependencies before continuing.

Terminal window
bun install

Bun publishes the @types/bun package, containing the runtime types for Bun.

Install @types/bun using the following command:

Terminal window
bun add -d @types/bun

You can also use any of the official Astro integrations with the astro add command:

Terminal window
bun astro add react

You can start a new Astro project based on an official example or the main branch of any GitHub repository by passing a --template argument to the create astro command.

Run the following command in your terminal, substituting the official Astro starter template name, or the GitHub username and repository of the theme you want to use:

Terminal window
# create a new project with an official example
bun create astro@latest --template <example-name>
# create a new project based on a GitHub repository’s main branch
bun create astro@latest --template <github-username>/<github-repo>

To run the development server, use following command:

Terminal window
bun run dev

To build your site, use the following command:

Terminal window
bun run build

When the build is finished, run the appropriate preview command (e.g. bun run preview) in your terminal and you can view the built version of your site locally in the same browser preview window.

Bun ships with a fast, built-in, Jest-compatible test runner through the bun test command. You can also use any other testing tools for Astro.

Using Bun with Astro? Add your blog post or video to this page!

Pomóż nam Społeczność Sponsor