This adapter allows Astro to run your SSR site with the Bun's native API Bun.serve
.
- Bun
- Install
astro-bun
package
bun add astro-bun
- Update your
astro.config.mjs
to useastro-bun
adapter.
// astro.config.mjs
import { defineConfig } from 'astro/config';
import bun from 'astro-bun';
export default defineConfig({
output: 'server',
adapter: bun(),
});
- Build your project.
bunx --bun astro build
This will generate an entry.mjs
script inside ./dist/server
.
- Run the
entry.mjs
script.
bun run ./dist/server/entry.mjs
or, you can update the preview
script in you package.json
.
// package.json
{
// ...
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "bun run ./dist/server/entry.mjs"
}
}
and then just run:
bunx --bun astro preview