# Fumadocs (Framework Mode, Astro): Local Markdown (Sätteri)
URL: /docs/astro/integrations/content/satteri-local-md
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/integrations/content/satteri-local-md.mdx

Content source for local Markdown content, compiled with Sätteri.

## Introduction [#introduction]

`@fumadocs/satteri/local-md` is a content source for local Markdown/MDX files, compiled with [Sätteri](https://github.com/bruits/satteri) instead of the unified/remark pipeline.

It has the same API as [`@fumadocs/local-md`](/docs/astro/integrations/content/local-md) and is also bundleless, so it works at runtime with no type-gen or bundler step.

Use it when you want the Sätteri compiler, its plugin model, and the Fumadocs Sätteri preset.

### Differences [#differences]

- Compilation always produces JavaScript, so there is no virtual JavaScript engine option. Rendering uses the native engine.
- Plugins are Sätteri plugins, configured through `satteriOptions`, not remark/rehype plugins.

<Callout type="warn">
Do not put untrusted Markdown/MDX files in `dir`, they can run as JavaScript or reference server-side files.
</Callout>

## Setup [#setup]

```package-install
@fumadocs/satteri shiki
```

> `shiki` is installed because it has to be externalized by the bundler.

Create a `localMd` instance and connect it to Fumadocs:

```ts title="lib/source.ts"
import { dynamicLoader } from 'fumadocs-core/source';
import { localMd } from '@fumadocs/satteri/local-md';

const docs = localMd({
  dir: 'content/docs',
});

const docsLoader = dynamicLoader(docs.dynamicSource(), {
  baseUrl: '/docs',
});

export async function getSource() {
  return docsLoader.get();
}
```

### Schema [#schema]

Pass `frontmatterSchema` and `metaSchema` to customize the validation schemas:

```ts title="lib/source.ts"
import { localMd } from '@fumadocs/satteri/local-md';
import { pageSchema, metaSchema } from 'fumadocs-core/source/schema';

const docs = localMd({
  dir: 'content/docs',
  frontmatterSchema: pageSchema.extend({
    // ...
  }),
  metaSchema: metaSchema.extend({
    // ...
  }),
});
```

### Compiler Options [#compiler-options]

`satteriOptions` is passed through the Fumadocs Sätteri preset, so plugins and their options are configured the same way as in Fumadocs MDX:

```ts title="lib/source.ts"
const docs = localMd({
  dir: 'content/docs',
  satteriOptions: {
    rehypeCodeOptions: {
      themes: { light: 'github-light', dark: 'github-dark' },
    },
    mdastPlugins: [myPlugin()],
  },
});
```

Pass a function to build the options lazily.

## Usage [#usage]

`getSource()` returns a [content loader](/docs/headless/source-api). Render pages the same way as [`@fumadocs/local-md`](/docs/astro/integrations/content/local-md#rendering-pages), importing from `@fumadocs/satteri/local-md` instead.

Each page has `load()`, which compiles the page and returns a renderer:

```tsx
const page = source.getPage(slugs);
const { body, toc } = await (await page.data.load()).render();
```

The renderer also has `structuredData` and `exports` for values the document or its plugins exported.

### Client Rendering [#client-rendering]

`serialize()` returns a JSON-safe payload of the compiled page.

Pass it from your page to a React island, and render it there:

```tsx
const serialized = (await page.data.load()).serialize();
```

```tsx title="components/content.tsx"
'use client';
import {
  rendererFromSerialized,
  type MarkdownRendererSerializedOptions,
} from '@fumadocs/satteri/local-md/client';

export function Content({ serialized }: { serialized: MarkdownRendererSerializedOptions }) {
  return rendererFromSerialized(serialized).renderSync().body;
}
```

### Include [#include]

[`<include>`](/docs/mdx/include) and the `::include` directive are enabled by default:

```mdx title="content/docs/page.mdx"
<include>../shared/note.md</include>
```

### Hot Reload [#hot-reload]

The source reads files at runtime, so nothing watches them by default.

During development, the Vite plugin invalidates the source through Vite's file watcher. Add the plugin to your config and connect the source:

```js tab="astro.config.mjs"
import { defineConfig } from 'astro/config';
import { localContentPlugin } from '@fumadocs/satteri/local-md/dev/vite';

export default defineConfig({
  vite: {
    plugins: [localContentPlugin()],
  },
});
```

```ts tab="lib/source.ts"
import { watchWithVite } from '@fumadocs/satteri/local-md/dev/vite';

if (import.meta.env.DEV) {
  watchWithVite(docs);
}
```

Included files are watched too. To wire up your own watcher, watch `docs.dir` and the files passed to `docs.onDependency()`, then call `docs.invalidateFile(path)` when a file changes.

### Disable Revalidation [#disable-revalidation]

Use `staticSource()` when you only need a one-time snapshot, so a normal `loader()` works:

```ts title="lib/source.ts"
import { loader } from 'fumadocs-core/source';

export const source = loader(await docs.staticSource(), {
  baseUrl: '/docs',
});
```