Skip to Content
Fumadocs

Bun

Access content in Bun.

Setup

Register the plugin in preload script:

preload = ["./scripts/preload.ts"]

The plugin loads MDX and meta files at runtime. Its setup is asynchronous, so await it. Without await, your scripts import lib/source.ts before the plugin is ready, and the Macro API throws an error.

Now running any script with Bun, you can access your content files directly.

Re-generate .source folder

Optionally, you can re-generate the .source folder.

It is useful when the folder could be missing, or you are on a Vite framework (React Router, TanStack Start, Waku), which defaults to generating code with Vite-specific APIs.

scripts/preload.ts
import { postInstall } from 'fumadocs-mdx/next';

await postInstall({ configPath: 'source.config.ts' });

How is this guide?