# Fumadocs (Framework Mode, Next.js): クイックスタート
URL: /ja/docs/next
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/index.ja.mdx

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]

**Markdown/MDX:** Markdown は、書式付きテキストを作成するためのマークアップ言語です。Fumadocs は Markdown と MDX (Markdown のスーパーセット) をネイティブにサポートしています。

**[Bun](https://bun.sh):** JavaScript ランタイムです。本ガイドではスクリプトの実行に使用します。Node.js を使いたい場合は、代わりに [unrun](https://gugustinette.github.io/unrun/guide/getting-started.html#cli) をお試しください。

より高度なカスタマイズを行うには、React.js の基本的な知識があると役立ちます。

## 自動インストール [#automatic-installation]

Node.js 22以上が必要です。

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

使用する組み込みテンプレートを選択するよう求められます。

* **フレームワーク**: Next.js、React Router、TanStack Start、Waku、Astro
* **コンテンツソース**: Fumadocs MDX、または Astro のコンテンツコレクション

新しい Fumadocs アプリが初期化され、以下の機能がデフォルトで設定されます。

* [LLM 連携](/docs/next/integrations/llms)
* [動的なメタデータ画像](/docs/next/integrations/og)

<Callout title="既存のコードベースに導入する場合">
[手動インストール](/docs/next/manual-installation)ガイドに従ってセットアップしてください。
</Callout>

### お楽しみください！ [#enjoy]

docs フォルダーに最初の MDX ファイルを作成しましょう。

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

## Yo what's up
```

開発モードでアプリを起動します。

```npm
npm run dev
```

http://localhost:3000/docs を開くと、作成したページを確認できます。

## よくある質問 [#faq]

よく寄せられる質問をまとめています。

<Accordions>
<Accordion id="upgrade-fumadocs" title="APIが見つからない、バグがあるなどの理由でエラーが発生していますか?">
お探しのAPIや修正は、新しいバージョンで提供されている可能性があります。[Fumadocsをアップグレード](/docs/next/upgrade)してから、もう一度お試しください。
</Accordion>

<Accordion id="change-base-url" title="ドキュメントのベースルートはどうすれば変更できますか?">
ルーティングは Next.js が処理します。まず docs ルートを移動してください (`/docs/*` -&gt; `/info/*`) 。

ルートの名前を変更します。

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

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

または、ルートグループを使用して `/docs/*` を `/*` に変更することもできます。

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

最後に、`source.ts` でページのベース URL を更新します。

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

export const source = loader({
  baseUrl: '/info', // 新しい値に変更 [!code highlight]
});
```

テンプレートでは、この値は `lib/shared.ts` 内で `docsRoute` として定義されています。Markdown のリンクにも反映されるよう、変更する際はこの値を編集してください。
</Accordion>

<Accordion id="multi-docs" title="複数のドキュメントを実装するにはどうすればよいですか?">
[レイアウトタブ](/docs/ui/layouts/docs#layout-tabs)の使用をおすすめします。
</Accordion>

<Accordion id="custom-layout-docs-page" title="Docs レイアウトを使わずに /docs 配下にページを作成するには?">
Next.js App Router でのレイアウト管理と同様に、コンテンツディレクトリ(`/content/docs`)から元の MDX ファイルを削除します。
これにより、ページの重複によるエラーを防げます。

次に、Docs レイアウトの配下にない別のルートグループにページを追加します。

例えば、`/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>

`/docs` の場合は、catch-all ルートを 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="Node.js の既知の問題">
次のような Turbopack のエラーが発生する場合:

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

通常、`require(esm)` がサポートされていないことが原因です([#3312](https://github.com/fuma-nama/fumadocs/issues/3312))。Node.js 22 以上にアップグレードしてください。

Node.js 23.1 で、本番ビルド時に次のエラーが発生した場合:

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

これは既知の問題です([#1021](https://github.com/fuma-nama/fumadocs/issues/1021) を参照)。Node.js を 23.6.0 以上にアップグレードしてください。
</Accordion>

<Accordion id="dynamic-route" title="動的ルートを使用していますが、パフォーマンスに問題はありませんか?">
Next.js では、`generateStaticParams` を設定すると動的ルートが静的ルートに変換されます。
そのため、静的ページと同等の速度で表示されます。

[静的エクスポートを有効にする](/docs/next/deploying/static)と、静的なビルド出力を得ることもできます。
</Accordion>
</Accordions>

## さらに詳しく [#learn-more]

初めての方もご安心ください。ご質問はいつでも歓迎しています。

わかりにくい点があれば、[Github Discussion](https://github.com/fuma-nama/fumadocs/discussions) でぜひフィードバックをお寄せください！

### コンテンツの執筆 [#writing-content]

ドキュメントを執筆する際は、以下を必ずお読みください。

<Cards>
<Card href="/docs/markdown" title="Markdown">
/docs/next/markdown" title="Markdown">
  Fumadocs には、コンテンツ執筆に役立つ追加機能がいくつか用意されています。
</Card>

<Card href="/docs/navigation" title="ナビゲーション">
/docs/next/navigation" title="ナビゲーション">
  ナビゲーション構造をカスタマイズする方法を説明します。
</Card>

<Card href="/docs/page-conventions" title="ページスラッグとページツリー">
/docs/next/page-conventions" title="ページスラッグとページツリー">
  コンテンツを整理する方法を説明します。
</Card>

<Card href="/docs/ui/components" title="コンポーネント" description="ドキュメントを充実させるために利用できるコンポーネントの一覧です" />
</Cards>

### 特殊な要件 [#special-needs]

<Cards>
<Card href="/docs/deploying/static" title="静的エクスポートの設定" description="ドキュメントで静的エクスポートを有効にする方法を説明します">
/docs/next/deploying/static
</Card>

<Card href="/docs/internationalization" title="国際化" description="i18n を有効にする方法を説明します">
/docs/next/internationalization
</Card>

<Card href="/docs/ui/theme" title="カラーテーマ" description="Fumadocs UI にテーマを追加します" />

<Card href="/docs/ui/layouts" title="レイアウト" description="Fumadocs UI のレイアウトをカスタマイズします" />
</Cards>