Bun
How to use SvelteKit OG with the official Bun adapter (@sveltejs/adapter-bun)
This section details the configuration needed to run SvelteKit OG on the Bun runtime with the official Bun adapter (@sveltejs/adapter-bun). Both engines work: Satori + ReSVG take the Node code path (the wasm is read from node_modules), and Takumi resolves its native backend through its bun export condition.
Requirements
@sveltejs/adapter-bun needs SvelteKit 3 and Bun 1.4 or newer. The adapter also requires the build itself to run under Bun — vite build started by Node fails with "adapter-bun requires running the SvelteKit build with Bun".
Installation
Install the Bun adapter:
pnpm i -D @sveltejs/adapter-bun
npm i -D @sveltejs/adapter-bun
yarn add -D @sveltejs/adapter-bun
bun add -D @sveltejs/adapter-bun
deno add --dev npm:@sveltejs/adapter-bun
SvelteKit 3 has no svelte.config.js; pass the adapter to sveltekit() in vite.config.js:
import adapter from '@sveltejs/adapter-bun';
import { sveltekit } from '@sveltejs/kit/vite';
import { sveltekitOG } from '@ethercorps/sveltekit-og/plugin';
const config = {
plugins: [sveltekit({ adapter: adapter() }), sveltekitOG({ esmImport: false })]
};
export default config;
Plugin Configuration
Use the sveltekitOG Vite plugin with { esmImport: false }, exactly as on Node: the Wasm module is then loaded with Bun's Node-compatible file APIs instead of an ESM .wasm import. The plugin only touches the server bundle, so the client-side entry keeps working alongside it.
Build and run
Build with Bun (not Node) and start the generated server:
{
"scripts": {
"build": "bun run --bun vite build",
"start": "bun ./build"
}
}
bun run build
bun run start
The server listens on PORT (default 3000). See the adapter docs for HOST, SOCKET_PATH, proxy headers and the other environment variables.
Usage
Once configured, usage is the same as any other SvelteKit environment.
- Svelte Components: refer to the Svelte Component usage.
- Raw HTML: refer to the Raw HTML section for string templates.
- Takumi: refer to the Takumi engine page.
Preview (Self Test)
Source: https://github.com/etherCorps/sveltekit-og/tree/main/examples/bun-build
Step-by-Step Guide
- Clone the repository and navigate:
git clone https://github.com/etherCorps/sveltekit-og.git
cd sveltekit-og/examples/bun-build
- Install dependencies:
pnpm install
- Build with Bun:
bun run build
- Start the server:
bun run start
Then open http://localhost:3000 to browse the example gallery — the PNG, SVG and Takumi routes, each as an HTML string, a Svelte component, and a pre-rendered image, plus the client-side renders.
More on how to use adapter-bun in SvelteKit