# Fumadocs (Framework Mode, Next.js): Quick Start
URL: /docs/next
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/index.mdx

Getting Started with Fumadocs

# Set up Fumadocs

Instructions for AI agents to set up Fumadocs on Next.js. The setup changes between versions, so run the commands below and read the linked docs instead of writing the setup from memory. Add `.md` to the URL of a docs page to read it as Markdown.

## New Site

Create a new docs site in a new folder, or as a workspace package of a monorepo:

```bash
npx create-fumadocs-app@latest my-docs --template +next+fuma-docs-mdx --install --yes
```

For a static site, use the `+next+fuma-docs-mdx+static` template.

- `my-docs` is the folder to create.
- `--yes` skips the prompts, and the options you don't pass use their defaults. The options are listed in https://fumadocs.dev/docs/cli/create-fumadocs-app.md

## Existing App

To add docs to an existing app, run the CLI in the folder of the app:

```bash
npx @fumadocs/cli@latest init
```

- The CLI detects the framework, and adds the docs pages with their own layout beside the existing routes.
- `--i18n` sets up internationalization.
- The CLI asks before it overwrites a file. Without a terminal, it keeps the file and prints its name. Pass `--yes` only when every file it writes can be overwritten.

To set up by hand, or to merge a file that the CLI kept, follow https://fumadocs.dev/docs/next/manual-installation.md

## After the Setup

Both commands print the next steps. Start the dev server and open the docs, at `/docs` unless the output names another path.

For the tasks that follow, read the docs page of the task first:

- Writing pages: https://fumadocs.dev/docs/next/markdown.md
- Organizing pages and folders: https://fumadocs.dev/docs/next/page-conventions.md
- Customizing the UI: https://fumadocs.dev/docs/next/guides/customize-ui.md
- Changing the theme and colors: https://fumadocs.dev/docs/ui/theme.md
- Other tasks: https://fumadocs.dev/llms.txt lists every docs page.

## Terminology [#terminology]

**Markdown/MDX:** Markdown is a markup language for creating formatted text. Fumadocs natively supports Markdown and MDX (superset of Markdown).

**[Bun](https://bun.sh):** A JavaScript runtime, it will be used in our guides for running scripts. If you prefer Node.js, try [unrun](https://gugustinette.github.io/unrun/guide/getting-started.html#cli) instead.

Some basic knowledge of React.js would be useful for further customizations.

## Automatic Installation [#automatic-installation]

A minimum version of Node.js 22 required.

```npm
npm create fumadocs-app
```

It will ask you the built-in template to use:

- **Framework**: Next.js, React Router, TanStack Start, Waku and Astro.
- **Content source**: Fumadocs MDX, or Astro content collections.

A new fumadocs app should be initialized, with following features configured by default:

- [LLM integration](/docs/next/integrations/llms).
- [Dynamic metadata image](/docs/next/integrations/og).

<Callout title="From Existing Codebase?">
You can follow the [Manual Installation](/docs/next/manual-installation) guide to get started.
</Callout>

### Enjoy! [#enjoy]

Create your first MDX file in the docs folder.

```mdx title="content/docs/index.mdx"
---
title: Hello World
---

## Yo what's up
```

Run the app in development mode:

```npm
npm run dev
```

Open http://localhost:3000/docs to see your page.

## FAQ [#faq]

Some common questions you may encounter.

<Accordions>
<Accordion id="upgrade-fumadocs" title="Getting error with missing APIs or bugs?">
The API or the fix may be in a newer version. [Upgrade Fumadocs](/docs/next/upgrade) and try again.
</Accordion>

<Accordion id="change-base-url" title="How to change the base route of docs?">
Routing is handled by Next.js. Move the docs route first (`/docs/*` -> `/info/*`).

Rename the route:

<Files>
<Folder name="app/docs" defaultOpen disabled>
<File name="layout.tsx" />
</Folder>

<Folder name="app/info" defaultOpen>
<File name="layout.tsx" />
</Folder>
</Files>

Or rename from `/docs/*` to `/*` using a route group:

<Files>
<Folder name="app/(docs)" defaultOpen>
<File name="layout.tsx" />
</Folder>
</Files>

Finally, update the base URL of pages in `source.ts`:

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

export const source = loader({
  baseUrl: '/info', // to the new value [!code highlight]
});
```

The templates define this value as `docsRoute` in `lib/shared.ts`, change it there so Markdown links follow.
</Accordion>

<Accordion id="multi-docs" title="How to implement multi-docs?">
We recommend using [Layout Tabs](/docs/ui/layouts/docs#layout-tabs).
</Accordion>

<Accordion id="custom-layout-docs-page" title="How to create a page in /docs without docs layout?">
Same as managing layouts in Next.js App Router, remove the original MDX file from content directory (`/content/docs`).
This ensures duplicated pages will not cause errors.

Now, You can add the page to another route group, which isn't a descendant of docs layout.

For example, to replace `/docs/test`:

<Files>
<File name="(home)/docs/test/page.tsx" />

<Folder name="docs" defaultOpen>
<File name="layout.tsx" />

<File name="[[...slug]]/page.tsx" />
</Folder>
</Files>

For `/docs`, you need to change the catch-all route to be non-optional:

<Files>
<File name="(home)/docs/page.tsx" />

<Folder name="docs" defaultOpen>
<File name="layout.tsx" />

<File name="[...slug]/page.tsx" />
</Folder>
</Files>
</Accordion>

<Accordion id="node-issues" title="Known Node.js issues">
If you have similar Turbopack errors like:

```
JSON file not found: FileSystemPath { ... path: "lib/locales/sources/file.json.json" }
```

It is usually because `require(esm)` is not supported ([#3312](https://github.com/fuma-nama/fumadocs/issues/3312)), please upgrade to Node.js 22+.

On Node.js 23.1, if you encountered this error in production build:

```
Could not find a production build in the '.next' directory.
```

It is a known problem, see [#1021](https://github.com/fuma-nama/fumadocs/issues/1021), you can upgrade your Node.js version to 23.6.0+.
</Accordion>

<Accordion id="dynamic-route" title="It uses Dynamic Route, will it be poor in performance?">
Next.js turns dynamic route into static routes when `generateStaticParams` is configured.
Hence, it is as fast as static pages.

You can [enable static export](/docs/next/deploying/static) to get a static build output.
</Accordion>
</Accordions>

## Learn More [#learn-more]

New to here? Don't worry, we are welcome for your questions.

If you find anything confusing, please give your feedback on [Github Discussion](https://github.com/fuma-nama/fumadocs/discussions)!

### Writing Content [#writing-content]

For authoring docs, make sure to read:

<Cards>
<Card href="/docs/markdown" title="Markdown">
/docs/next/markdown" title="Markdown">
  Fumadocs has some additional features for authoring content.
</Card>

<Card href="/docs/navigation" title="Navigation">
/docs/next/navigation" title="Navigation">
  Learn how to customize navigation structure.
</Card>

<Card href="/docs/page-conventions" title="Page Slugs & Page Tree">
/docs/next/page-conventions" title="Page Slugs & Page Tree">
  Learn how to organise content.
</Card>

<Card href="/docs/ui/components" title="Components" description="See all available components to enhance your docs" />
</Cards>

### Special Needs [#special-needs]

<Cards>
<Card href="/docs/deploying/static" title="Configure Static Export" description="Learn how to enable static export on your docs">
/docs/next/deploying/static
</Card>

<Card href="/docs/internationalization" title="Internationalization" description="Learn how to enable i18n">
/docs/next/internationalization
</Card>

<Card href="/docs/ui/theme" title="Color Themes" description="Add themes to Fumadocs UI" />

<Card href="/docs/ui/layouts" title="Layouts" description="Customize your Fumadocs UI layouts" />
</Cards>