andremralves / astro-bun

An Astro adapter that allows you to run your SSR site with Bun's native API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

astro-bun

This adapter allows Astro to run your SSR site with the Bun's native API Bun.serve.

Prerequisites

  • Bun

Installation

  1. Install astro-bun package
bun add astro-bun
  1. Update your astro.config.mjs to use astro-bun adapter.
// astro.config.mjs
import { defineConfig } from 'astro/config';
import bun from 'astro-bun';

export default defineConfig({
  output: 'server',
  adapter: bun(),
});
  1. Build your project.
bunx --bun astro build

This will generate an entry.mjs script inside ./dist/server.

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

About

An Astro adapter that allows you to run your SSR site with Bun's native API.

License:MIT License


Languages

Language:TypeScript 91.7%Language:JavaScript 8.3%