# Fumadocs MDX (the built-in content source): Bun
URL: /docs/mdx/loader/bun
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/mdx/(integrations)/loader/bun.mdx

Access content in Bun.

## Setup [#setup]

Register the plugin in preload script:

```toml tab="bunfig.toml"
preload = ["./scripts/preload.ts"]
```

```ts tab="scripts/preload.ts"
import { createMdxPlugin } from 'fumadocs-mdx/bun';

await Bun.plugin(createMdxPlugin());
```

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](/docs/mdx/macro) throws an error.

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

### Re-generate `.source` folder [#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.

```ts title="scripts/preload.ts" tab="Next.js"
import { postInstall } from 'fumadocs-mdx/next';

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

```ts title="scripts/preload.ts" tab="Vite"
import { postInstall } from 'fumadocs-mdx/vite';

await postInstall({
  configPath: 'source.config.ts',
  index: {
    target: 'bun',
  },
});
```