# Fumadocs (Framework Mode): Comparisons
URL: /docs/comparisons
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/comparisons.mdx
How is Fumadocs different from other existing frameworks?
Nextra [#nextra]
Fumadocs is highly inspired by Nextra. For example, the Routing Conventions. That is why
`meta.json` also exists in Fumadocs.
Nextra is more opinionated than Fumadocs, as a side effect, you have to
configure things manually compared to simply editing a configuration file.
Fumadocs works great if you want more control over everything, such as
adding it to an existing codebase or implementing advanced routing.
Feature Table [#feature-table]
| Feature | Fumadocs | Nextra |
| ------------------- | ------------ | ------------------------- |
| Static Generation | Yes | Yes |
| Cached | Yes | Yes |
| Light/Dark Mode | Yes | Yes |
| Syntax Highlighting | Yes | Yes |
| Table of Contents | Yes | Yes |
| Full-text Search | Yes | Yes |
| i18n | Yes | Yes |
| Last Git Edit Time | Yes | Yes |
| Page Icons | Yes | Yes, via `_meta.js` files |
| RSC | Yes | Yes |
| Remote Source | Yes | Yes |
| SEO | Via Metadata | Yes |
| Built-in Components | Yes | Yes |
| RTL Layout | Yes | Yes |
Additional Features [#additional-features]
Features supported via 3rd party libraries like [TypeDoc](https://typedoc.org) will not be listed here.
| Feature | Fumadocs | Nextra |
| -------------------------- | -------- | ------ |
| OpenAPI Integration | Yes | No |
| TypeScript Docs Generation | Yes | No |
| TypeScript Twoslash | Yes | Yes |
Mintlify [#mintlify]
Mintlify is a documentation service, as compared to Fumadocs, it offers a free tier but isn't completely free and open source.
Fumadocs is not as powerful as Mintlify, for example, the OpenAPI integration of Mintlify.
As the creator of Fumadocs, I wouldn't recommend switching to Fumadocs from Mintlify if you're satisfied with the current way you build docs.
However, I believe Fumadocs is a suitable tool for all React.js developers who want to have elegant docs.
Docusaurus [#docusaurus]
Docusaurus is a powerful framework based on React.js. It offers many cool
features with plugins and custom themes.
Lower Complexity [#lower-complexity]
As Fumadocs is designed to integrate with React frameworks, you may need more knowledge of React.js to get started.
In return, Fumadocs have better customizability.
For a simple docs, Docusaurus might be a better choice if you don't need any framework-specific functionality.
Plugins [#plugins]
You can easily achieve many things with plugins, their ecosystem is indeed larger and maintained by many contributors.
In comparison, the flexibility of Fumadocs allows you to implement them on your own, it may take longer to tune it to your satisfaction.
# Fumadocs (Framework Mode): Quick Start
URL: /docs
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/index.mdx
Getting Started with Fumadocs
Introduction [#introduction]
Fumadocs (Foo-ma docs) is a **documentation framework**, designed to be fast, flexible,
and composes seamlessly into your React framework.
Fumadocs has different parts:
} title="Fumadocs Core" href="/docs/headless">
Handles most of the logic, including document search, content source adapters, and Markdown extensions.
} title="Fumadocs UI" href="/docs/ui">
The default theme of Fumadocs offers a beautiful look for documentation sites and interactive components.
} title="Content Source">
The source of your content, can be a CMS or local data layers like [Fumadocs MDX](/docs/mdx) (the official content source).
} title="Fumadocs CLI" href="/docs/cli">
A command line tool to install UI components and automate things, useful for customizing layouts.
Read our in-depth [What is Fumadocs](/docs/what-is-fumadocs) introduction.
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, we use it for running scripts.
Some basic knowledge of React.js would be useful for further customisations.
Automatic Installation [#automatic-installation]
A minimum version of Node.js 22 required.
npm
pnpm
yarn
bun
```bash
npm create fumadocs-app
```
```bash
pnpm create fumadocs-app
```
```bash
yarn create fumadocs-app
```
```bash
bun create fumadocs-app
```
It will ask you the built-in template to use:
* **React.js framework**: Next.js, Waku, React Router, Tanstack Start.
* **Content source**: Fumadocs MDX.
A new fumadocs app should be initialized. Now you can start hacking!
You can follow the [Manual Installation](/docs/manual-installation) guide to get started.
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 and see [http://localhost:3000/docs](http://localhost:3000/docs).
npm
pnpm
yarn
bun
```bash
npm run dev
```
```bash
pnpm run dev
```
```bash
yarn dev
```
```bash
bun run dev
```
FAQ [#faq]
Some common questions you may encounter.
Make sure to upgrade Fumadocs when you've encountered any problems or trying out new features:
```bash title="pnpm"
pnpm update -i -r --latest
```
Routing is handled by your React framework, you need to change the routing structure first.
For example, in Next.js, rename the route (`/docs/*` -> `/info/*`):
Or rename from `/docs/*` to `/*` using a route group:
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]
});
```
We recommend to use [Sidebar Tabs](/docs/ui/layouts/docs#sidebar-tabs).
For Vite [#for-vite]
There's some weird pre-bundling problems with Vite: [#3910](https://github.com/vitejs/vite/issues/3910).
Make sure to exclude Fumadocs from pre-bundling and add it to `noExternal`:
```ts title="vite.config.ts"
import { defineConfig } from 'vite';
export default defineConfig({
resolve: {
// add other Fumadocs deps as needed
noExternal: ['fumadocs-core', 'fumadocs-ui', 'fumadocs-openapi', '@fumadocs/base-ui'],
},
});
```
For Next.js [#for-nextjs]
Node.js 23.1 might have problems with Next.js, see [#1021](https://github.com/fuma-nama/fumadocs/issues/1021). Make sure to change your Node.js version.
Next.js turns dynamic route into static routes when `generateStaticParams` is configured.
Hence, it is as fast as static pages.
You can [enable Static Exports](/docs/deploying/static) on Next.js to get a static build output.
Webpack resolves import namespace **before** your import aliases in `tsconfig.json`. When using Fumadocs MDX, you have to rename your import alias to `collections/*` instead.
```json title="tsconfig.json"
{
"compilerOptions": {
"paths": {
// [!code ++]
"collections/*": [".source/*"]
}
}
}
```
Make sure to update the references as well.
```ts title="lib/source.ts"
// [!code --]
import { docs } from 'fumadocs-mdx:collections/server';
// [!code ++]
import { docs } from 'collections/server';
```
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`:
For `/docs`, you need to change the catch-all route to be non-optional:
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:
Fumadocs has some additional features for authoring content.
Learn how to customise navigation structure.
Learn how to organise content.
Special Needs [#special-needs]
# Fumadocs (Framework Mode): Navigation
URL: /docs/navigation
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/navigation.mdx
Configure navigation in your Fumadocs app.
import { LinkIcon, PanelLeftDashed } from 'lucide-react';
**Fumadocs UI** provides different layouts to display content, you can specify navigation configurations via layouts.
} title="Layout Links" href="/docs/ui/layouts/links">
Display **navigation links** in your layouts.
It is useful for linking to frequently used resources like showcase and pricing pages.
} title="Sidebar Items" href="/docs/ui/layouts/docs#sidebar-items">
Sidebar renders links to all documentation pages.
Under the hood, **Page Tree** is used to represent the navigation structure.
# Fumadocs (Framework Mode): Page Slugs & Page Tree
URL: /docs/page-conventions
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/page-conventions.mdx
A shared convention for organizing your documents
>
> This guide only applies for content sources that uses `loader()` API, such as **Fumadocs MDX**.
>
Overview [#overview]
Fumadocs generates **page slugs** and **page tree** (sidebar items) from your content directory using [`loader()`](/docs/headless/source-api),
the routing functionality will be handled by your React framework.
You can define folders and pages similar to file-system based routing.
To customise its output further, you may use [Loader Plugins](/docs/headless/source-api/plugins).
File [#file]
For [MDX](https://mdxjs.com) & Markdown file, you can customise page information from frontmatter.
```mdx
---
title: My Page
description: Best document ever
icon: HomeIcon
---
## Learn More
```
Fumadocs detects from the following properties to construct page trees.
| name | description |
| ------------- | ------------------------------------- |
| `title` | The title of page |
| `description` | The description of page |
| `icon` | The name of icon, see [Icons](#icons) |
Page information is supplied by the content source such as **Fumadocs MDX**.
On Fumadocs MDX, you can specify a [`schema`](/docs/mdx/collections#schema-1) option to customise frontmatter schema.
Slugs [#slugs]
The slugs of a page are generated from its file path.
| path (relative to content folder) | slugs |
| --------------------------------- | ----------------- |
| `./dir/page.mdx` | `['dir', 'page']` |
| `./dir/index.mdx` | `['dir']` |
Folder [#folder]
Organize multiple pages, you can create a [Meta file](#meta) to customise folders.
Folder Group [#folder-group]
By default, putting a file into folder will change its slugs.
You can wrap the folder name in parentheses to avoid impacting the slugs of child files.
| path (relative to content folder) | slugs |
| --------------------------------- | ---------- |
| `./(group-name)/page.mdx` | `['page']` |
Root Folder [#root-folder]
Marks the folder as a root folder, only items in the opened root folder will be visible.
```json title="meta.json"
{
"title": "Name of Folder",
"description": "The description of root folder (optional)",
"root": true
}
```
For example, when you are opening root folder `framework`, the other folders (e.g. `headless`) are not shown on the sidebar and other navigation elements.
Fumadocs UI renders root folders as [Sidebar Tabs](/docs/ui/layouts/docs#sidebar-tabs), which allows user to switch between them.
Meta [#meta]
Customise folders by creating a `meta.json` file in the folder.
```json title="meta.json"
{
"title": "Display Name",
"icon": "MyIcon",
"pages": ["index", "getting-started"],
"defaultOpen": true
}
```
| name | description |
| ------------- | -------------------------------------------- |
| `title` | Display name |
| `icon` | The name of icon, see [Icons](#icons) |
| `defaultOpen` | Open the folder by default |
| `collapsible` | Collapsible folder content (default: `true`) |
| `pages` | Folder items (see below) |
Pages [#pages]
Folder items are sorted alphabetically by default, you can add or control the order of items using `pages`.
```json title="meta.json"
{
"pages": ["index", "getting-started"]
}
```
>
> When specified, items are not included unless they are listed in `pages`.
>
| Type | Syntax | Description |
| ----------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| **Path** | `./path/to/page` | a path to page or folder. |
| **Separator** | `---Label---` `---[Icon]Label---` | a separator between two sections (icon supported). |
| **Link** | `[Text](url)` `[Icon][Text](url)` `external:[Text](url)` | insert links (icon supported) add a `external:` prefix to mark links as external. |
| **Rest** | `...` | include remaining pages (sorted alphabetically). |
| **Reversed Rest** | `z...a` | reversed **Rest** item. |
| **Extract** | `...folder` | extract the items from a folder. |
| **Except** | `!item` | Exclude an item from `...` or `z...a`. |
```json title="meta.json"
{
"pages": [
"components",
"---My Separator---",
"...folder",
"...",
"!file",
"!otherFolder",
"[Vercel](https://vercel.com)",
"[Triangle][Vercel](https://vercel.com)"
]
}
```
Icons [#icons]
Since Fumadocs doesn't include an icon library, you have to convert the icon names to JSX elements in runtime, and render it as a component.
You can add an [`icon` handler](/docs/headless/source-api#icons) to `loader()`.
i18n Routing [#i18n-routing]
You can define different style for i18n routing.
```ts title="lib/i18n.ts"
import type { I18nConfig } from 'fumadocs-core/i18n';
export const i18n: I18nConfig = {
// default
parser: 'dot',
// or
parser: 'dir',
};
```
Add Markdown/meta files for different languages by attending `.{locale}` to your file name, like:
For the default locale, the locale code is optional.
All content files are grouped by language folders:
# Fumadocs (Framework Mode): Versioning
URL: /docs/versioning
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/versioning.mdx
Implementing multi-version in your docs.
Overview [#overview]
It's common for developer tool related docs to version their docs, such as different docs for v1 and v2 of the same tool.
Fumadocs provide the primitives for you to implement versioning on your own way.
Partial Versioning [#partial-versioning]
When versioning only applies to part of your docs, You can separate them by folders.
For example:
When grouping with folders, you can display them as tabs [using Sidebar
Tabs](/docs/ui/layouts/docs#sidebar-tabs).
Full Versioning [#full-versioning]
Sometimes you want to version the entire website, such as [https://v14.fumadocs.dev](https://v14.fumadocs.dev) (Fumadocs v14) and [https://fumadocs.dev](https://fumadocs.dev) (Latest Fumadocs).
You can create a Git branch for a version of docs (call it `v2` for example), and deploy it as a separate app on another subdomain like `v2.my-site.com`.
Optionally, you can link to the other versions from your docs.
This design allows some advantages over partial versioning:
* Easy maintenance: Old docs/branches won't be affected when you iterate or upgrade dependencies.
* Better consistency: Not just the docs itself, your landing page (and other pages) will also be versioned.
# Fumadocs (Framework Mode): What is Fumadocs
URL: /docs/what-is-fumadocs
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/what-is-fumadocs.mdx
Introducing Fumadocs, a docs framework that you can break.
The **Fumadocs** framework refers to a combination of UI + Core + Content Source, Fumadocs is more of a mental framework and each layer can be a library on its own.
Philosophy [#philosophy]
Fumadocs was created to bring a more customisable experience for building docs, to be a docs framework that is not opinionated, **a "framework" that you can break**.
Less Abstraction [#less-abstraction]
While most frameworks are configured with a configuration file, they usually lack flexibility when you hope to tune its details.
You can’t control how they render the page nor the internal logic.
Fumadocs expects you to write code and cooperate with the rest of your software, it shows you how the app works and fully customisable, instead of a configuration file.
Seamless Integration [#seamless-integration]
Fumadocs integrates tightly with your React framework, bringing useful utilities and a good-looking UI.
For Next.js developers, you are still using features of App Router, like **Static Site Generation**. There is nothing new for Next.js developers, that everything is familiar to you.
Composable UI [#composable-ui]
The only thing Fumadocs UI (the default theme) offers is **User Interface**. The UI is opinionated for bringing better mobile responsiveness and user experience.
Instead, we follow a much more flexible approach inspired by Shadcn UI — [Fumadocs CLI](/docs/cli), allowing you to "fork" a part of Fumadocs UI, and fully customise it.
Server-first Approach [#server-first-approach]
Traditionally, static site generators are **static**.
However, Fumadocs introduce a server-first approach powered by React Server Component.
With perfect server-client boundary, content becomes dynamic and interactive.
You can fetch data from server to display content, or integrate with CMS receiving realtime updates. It is always up-to-date and easy to maintain.
Minimal [#minimal]
Fumadocs is maintained by Fuma and many contributors, with care on the maintainability of codebase.
While we don't aim to offer every functionality people wanted, we're more focused on making basic features perfect and well-maintained.
You can also help Fumadocs to be more useful by contributing!
When to use Fumadocs [#when-to-use-fumadocs]
Fumadocs is designed with flexibility in mind, it is not limited to certain usages.
* `fumadocs-core` is a headless UI library for building docs.
* `fumadocs-mdx` is a useful library to handle MDX content.
For most of the web applications, vanilla React.js is no longer enough.
Nowadays, we also wish to have a blog, a showcase page, a FAQ page, etc. In these cases, Fumadocs can help you build the
docs easier, with less boilerplate.
You can read [Comparisons](/docs/comparisons) if you're interested.
Documentation [#documentation]
Fumadocs focuses on **authoring experience**, it provides a beautiful theme and many docs automation tools.
It helps you to iterate your codebase faster while never leaving your docs behind.
You can take this site as an example of docs site built with Fumadocs.
Blog sites [#blog-sites]
Most React.js frameworks can already suffice the needs of a blog site.
Fumadocs provides additional tooling, including syntax highlighting, document search, and a default theme (Fumadocs UI).
It helps you to avoid reinventing the wheels.
# Fumadocs CLI (the CLI tool for automating Fumadocs apps): create-fumadocs-app
URL: /docs/cli/create-fumadocs-app
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/cli/create-fumadocs-app.mdx
The CLI to create new Fumadocs apps
Overview [#overview]
Despite the classical CLI usage, you can also use it in scripts like:
npm
pnpm
yarn
bun
```bash
npm install create-fumadocs-app
```
```bash
pnpm add create-fumadocs-app
```
```bash
yarn add create-fumadocs-app
```
```bash
bun add create-fumadocs-app
```
```ts
import { create } from 'create-fumadocs-app';
await create({
outputDir: 'my-app',
template: '+next+fuma-docs-mdx',
packageManager: 'pnpm',
});
```
# Fumadocs CLI (the CLI tool for automating Fumadocs apps): User Guide
URL: /docs/cli
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/cli/index.mdx
The CLI tool that automates setups and installs components.
Installation [#installation]
Initialize a config for CLI:
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli
```
```bash
pnpm dlx @fumadocs/cli
```
```bash
yarn dlx @fumadocs/cli
```
```bash
bun x @fumadocs/cli
```
You can change the output paths of components in the config.
Components [#components]
Select and install components.
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli add
```
```bash
pnpm dlx @fumadocs/cli add
```
```bash
yarn dlx @fumadocs/cli add
```
```bash
bun x @fumadocs/cli add
```
You can pass component names directly.
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli add banner files
```
```bash
pnpm dlx @fumadocs/cli add banner files
```
```bash
yarn dlx @fumadocs/cli add banner files
```
```bash
bun x @fumadocs/cli add banner files
```
How the magic works? [#how-the-magic-works]
The CLI fetches the latest version of component from the GitHub repository of Fumadocs.
When you install a component, it is guaranteed to be up-to-date.
In addition, it also transforms import paths.
Make sure to use the latest version of CLI
>
> This is highly inspired by Shadcn UI.
>
Customise [#customise]
A simple way to customise Fumadocs layouts.
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli customise
```
```bash
pnpm dlx @fumadocs/cli customise
```
```bash
yarn dlx @fumadocs/cli customise
```
```bash
bun x @fumadocs/cli customise
```
Tree [#tree]
Generate files tree for Fumadocs UI `Files` component, using the `tree` command from your terminal.
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli tree ./my-dir ./output.tsx
```
```bash
pnpm dlx @fumadocs/cli tree ./my-dir ./output.tsx
```
```bash
yarn dlx @fumadocs/cli tree ./my-dir ./output.tsx
```
```bash
bun x @fumadocs/cli tree ./my-dir ./output.tsx
```
You can output MDX files too:
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli tree ./my-dir ./output.mdx
```
```bash
pnpm dlx @fumadocs/cli tree ./my-dir ./output.mdx
```
```bash
yarn dlx @fumadocs/cli tree ./my-dir ./output.mdx
```
```bash
bun x @fumadocs/cli tree ./my-dir ./output.mdx
```
See help for further details:
npm
pnpm
yarn
bun
```bash
npx @fumadocs/cli tree -h
```
```bash
pnpm dlx @fumadocs/cli tree -h
```
```bash
yarn dlx @fumadocs/cli tree -h
```
```bash
bun x @fumadocs/cli tree -h
```
Example Output [#example-output]
```tsx title="output.tsx"
import { File, Folder, Files } from 'fumadocs-ui/components/files';
export default (
);
```
# Fumadocs Core (the core library of Fumadocs): Introduction
URL: /docs/headless
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/index.mdx
Getting started with core library
What is this? [#what-is-this]
Fumadocs Core offers server-side functions and headless components to build docs on any React.js frameworks like Next.js.
* Search (built-in: Orama, Algolia Search)
* Breadcrumb, Sidebar, TOC Components
* Remark/Rehype Plugins
* Additional utilities
It can be used without Fumadocs UI, in other words, it's headless.
For beginners and normal usages, use [Fumadocs UI](/docs/ui).
Installation [#installation]
No other dependencies required.
npm
pnpm
yarn
bun
```bash
npm install fumadocs-core
```
```bash
pnpm add fumadocs-core
```
```bash
yarn add fumadocs-core
```
```bash
bun add fumadocs-core
```
For some components, a framework provider is needed:
Next.js
React Router
Tanstack Start/Router
Waku
```tsx
import type { ReactNode } from 'react';
import { NextProvider } from 'fumadocs-core/framework/next';
export function RootLayout({ children }: { children: ReactNode }) {
// or if you're using Fumadocs UI, use ``
return {children};
}
```
```tsx
import type { ReactNode } from 'react';
import { ReactRouterProvider } from 'fumadocs-core/framework/react-router';
export function Root({ children }: { children: ReactNode }) {
return {children};
}
```
```tsx
import type { ReactNode } from 'react';
import { TanstackProvider } from 'fumadocs-core/framework/tanstack';
export function Root({ children }: { children: ReactNode }) {
return {children};
}
```
```tsx
import type { ReactNode } from 'react';
import { WakuProvider } from 'fumadocs-core/framework/waku';
export function Root({ children }: { children: ReactNode }) {
return {children};
}
```
It offers simple document searching as well as components for building a
good docs.
# Fumadocs Core (the core library of Fumadocs): Internationalization
URL: /docs/headless/internationalization
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/internationalization.mdx
Support multiple languages in your documentation
Define Config [#define-config]
Fumadocs core provides necessary middleware and options for i18n support.
You can define a config to share between utilities.
```ts title="lib/i18n.ts"
import { defineI18n } from 'fumadocs-core/i18n';
export const i18n = defineI18n({
defaultLanguage: 'en',
languages: ['en', 'cn'],
});
```
Hide Locale Prefix [#hide-locale-prefix]
To hide the locale prefix (e.g. `/en/page` -> `/page`), use the `hideLocale` option.
```ts
import { defineI18n } from 'fumadocs-core/i18n';
export const i18n = defineI18n({
defaultLanguage: 'en',
languages: ['en', 'cn'],
hideLocale: 'default-locale',
});
```
| Mode | Description |
| ---------------- | -------------------------------------------------- |
| `always` | Always hide the prefix, detect locale from cookies |
| `default-locale` | Only hide the default locale |
| `never` | Never hide the prefix (default) |
Using always>}>
On `always` mode, locale is stored as a cookie (set by the middleware), which isn't optimal for static sites.
This may cause undesired cache problems, and need to pay extra attention on SEO to ensure search engines can index your pages correctly.
Fallback Language [#fallback-language]
The fallback language to use when translations are missing for a page, default to your `defaultLanguage`.
Supported:
* A language in your `languages` array.
* When set to `null`, no fallback will be used.
```ts
import { defineI18n } from 'fumadocs-core/i18n';
export const i18n = defineI18n({
languages: ['en', 'cn'],
defaultLanguage: 'en',
fallbackLanguage: 'cn',
});
```
Middleware [#middleware]
Redirects users to appropriate locale, it can be customised from `i18n.ts`.
```ts title="proxy.ts"
import { createI18nMiddleware } from 'fumadocs-core/i18n/middleware';
import { i18n } from '@/lib/i18n';
export default createI18nMiddleware(i18n);
export const config = {
// Matcher ignoring `/_next/` and `/api/`
// You may need to adjust it to ignore static assets in `/public` folder
matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};
```
>
> When `hideLocale` is enabled, it uses `NextResponse.rewrite` to hide locale prefixes.
>
# Fumadocs Core (the core library of Fumadocs): Page Slugs & Page Tree
URL: /docs/headless/page-conventions
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/page-conventions.mdx
Customise generated page slugs and page tree.
>
> This guide only applies for content sources that uses `loader()` API, such as **Fumadocs MDX**.
>
Overview [#overview]
Fumadocs generates **page slugs** and **page tree** (sidebar items) from your content directory using [`loader()`](/docs/headless/source-api),
the routing functionality will be handled by your React framework.
You can define folders and pages similar to file-system based routing.
To customise its output further, you may use [Loader Plugins](/docs/headless/source-api/plugins).
File [#file]
For [MDX](https://mdxjs.com) & Markdown file, you can customise page information from frontmatter.
```mdx
---
title: My Page
description: Best document ever
icon: HomeIcon
---
## Learn More
```
Fumadocs detects from the following properties to construct page trees.
| name | description |
| ------------- | ------------------------------------- |
| `title` | The title of page |
| `description` | The description of page |
| `icon` | The name of icon, see [Icons](#icons) |
Page information is supplied by the content source such as **Fumadocs MDX**.
On Fumadocs MDX, you can specify a [`schema`](/docs/mdx/collections#schema-1) option to customise frontmatter schema.
Slugs [#slugs]
The slugs of a page are generated from its file path.
| path (relative to content folder) | slugs |
| --------------------------------- | ----------------- |
| `./dir/page.mdx` | `['dir', 'page']` |
| `./dir/index.mdx` | `['dir']` |
Folder [#folder]
Organize multiple pages, you can create a [Meta file](#meta) to customise folders.
Folder Group [#folder-group]
By default, putting a file into folder will change its slugs.
You can wrap the folder name in parentheses to avoid impacting the slugs of child files.
| path (relative to content folder) | slugs |
| --------------------------------- | ---------- |
| `./(group-name)/page.mdx` | `['page']` |
Root Folder [#root-folder]
Marks the folder as a root folder, only items in the opened root folder will be visible.
```json title="meta.json"
{
"title": "Name of Folder",
"description": "The description of root folder (optional)",
"root": true
}
```
For example, when you are opening root folder `framework`, the other folders (e.g. `headless`) are not shown on the sidebar and other navigation elements.
Fumadocs UI renders root folders as [Sidebar Tabs](/docs/ui/layouts/docs#sidebar-tabs), which allows user to switch between them.
Meta [#meta]
Customise folders by creating a `meta.json` file in the folder.
```json title="meta.json"
{
"title": "Display Name",
"icon": "MyIcon",
"pages": ["index", "getting-started"],
"defaultOpen": true
}
```
| name | description |
| ------------- | -------------------------------------------- |
| `title` | Display name |
| `icon` | The name of icon, see [Icons](#icons) |
| `defaultOpen` | Open the folder by default |
| `collapsible` | Collapsible folder content (default: `true`) |
| `pages` | Folder items (see below) |
Pages [#pages]
Folder items are sorted alphabetically by default, you can add or control the order of items using `pages`.
```json title="meta.json"
{
"pages": ["index", "getting-started"]
}
```
>
> When specified, items are not included unless they are listed in `pages`.
>
| Type | Syntax | Description |
| ----------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------------------- |
| **Path** | `./path/to/page` | a path to page or folder. |
| **Separator** | `---Label---` `---[Icon]Label---` | a separator between two sections (icon supported). |
| **Link** | `[Text](url)` `[Icon][Text](url)` `external:[Text](url)` | insert links (icon supported) add a `external:` prefix to mark links as external. |
| **Rest** | `...` | include remaining pages (sorted alphabetically). |
| **Reversed Rest** | `z...a` | reversed **Rest** item. |
| **Extract** | `...folder` | extract the items from a folder. |
| **Except** | `!item` | Exclude an item from `...` or `z...a`. |
```json title="meta.json"
{
"pages": [
"components",
"---My Separator---",
"...folder",
"...",
"!file",
"!otherFolder",
"[Vercel](https://vercel.com)",
"[Triangle][Vercel](https://vercel.com)"
]
}
```
Icons [#icons]
Since Fumadocs doesn't include an icon library, you have to convert the icon names to JSX elements in runtime, and render it as a component.
You can add an [`icon` handler](/docs/headless/source-api#icons) to `loader()`.
i18n Routing [#i18n-routing]
You can define different style for i18n routing.
```ts title="lib/i18n.ts"
import type { I18nConfig } from 'fumadocs-core/i18n';
export const i18n: I18nConfig = {
// default
parser: 'dot',
// or
parser: 'dir',
};
```
Add Markdown/meta files for different languages by attending `.{locale}` to your file name, like:
For the default locale, the locale code is optional.
All content files are grouped by language folders:
# Fumadocs Core (the core library of Fumadocs): Page Tree
URL: /docs/headless/page-tree
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/page-tree.mdx
The structure of page tree.
Page tree is a tree structure that describes all navigation links, with other items like separator and folders.
It will be sent to the client and being referenced in navigation elements including the sidebar and breadcrumb.
Hence, you shouldn't store any sensitive or large data in page tree.
By design, page tree only contains necessary information of all pages and folders.
Unserializable data such as functions can't be passed to page tree.
Conventions [#conventions]
You can import the type definitions of page tree, useful if you want to hardcode or generate it.
```ts
import type * as PageTree from 'fumadocs-core/page-tree';
const tree: PageTree.Root = {
// props
};
```
Certain nodes contain a `$ref` property, they are internal and not used when hardcoding it.
Root [#root]
The initial root of page trees.
Page [#page]
A node representing link.
```json
{
"type": "page",
"name": "Quick Start",
"url": "/docs"
}
```
>
> External urls are also supported
> tag).\n\nWhen unspecified, it depends on the value of `url`.",
"tags": [],
"type": "boolean | undefined",
"simplifiedType": "boolean",
"required": false,
"deprecated": false
},
{
"name": "description",
"description": "",
"tags": [],
"type": "ReactNode",
"simplifiedType": "ReactNode",
"required": false,
"deprecated": false
},
{
"name": "icon",
"description": "",
"tags": [],
"type": "ReactNode",
"simplifiedType": "ReactNode",
"required": false,
"deprecated": false
},
{
"name": "$id",
"description": "ID for the node, unique in all page trees (even across different locales)",
"tags": [],
"type": "string | undefined",
"simplifiedType": "string",
"required": false,
"deprecated": false
}
]
}}
/>
Folder [#folder]
A node containing multiple children nodes.
```json
{
"type": "folder",
"name": "Guide",
"index": {
"type": "page",
...
}
"children": [
...
]
}
```
Separator [#separator]
A label between items.
```json
{
"type": "separator",
"name": "Components"
}
```
Icons [#icons]
Icon is a `ReactElement`, supported by pages and folders.
# Fumadocs (Framework Mode): Scalar Example
URL: /docs/openapi
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/openapi/index.mdx
View the Scalar Galaxy example OpenAPI schema.
# Fumadocs UI (the default theme of Fumadocs): Component Library
URL: /docs/ui/component-library
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/ui/component-library.mdx
The underlying headless component library.
Overview [#overview]
Fumadocs UI maintains support for both **Base UI** and **Radix UI**, while it uses Radix UI by default.
The configuration may be different if you use Fumadocs CLI for customising components.
Base UI [#base-ui]
You can opt-in to use Base UI by replacing `fumadocs-ui` with the `@fumadocs/base-ui` package:
```json title="package.json"
{
"dependency": {
"fumadocs-ui": "npm:@fumadocs/base-ui@latest"
}
}
```
For Fumadocs CLI, also configure it in your `cli.json` config:
```json title="cli.json"
{
"uiLibrary": "base-ui"
}
```
# Fumadocs UI (the default theme of Fumadocs): Overview
URL: /docs/ui
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/ui/index.mdx
The default theme of Fumadocs
**Fumadocs UI** offers a beautifully designed theme for documentation sites.
It is bundled with many interactive components & layouts for docs sites, allowing low maintenance cost of code while receiving regular UI improvements.
You can also use [Fumadocs CLI](/docs/cli) to install the components locally and have full control.
Learn More [#learn-more]
# Fumadocs UI (the default theme of Fumadocs): Search UI
URL: /docs/ui/search
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/ui/search.mdx
The UI for document search
Overview [#overview]
You can customise Search UI from [``](/docs/ui/layouts/root-provider).
```tsx title="app/layout.tsx"
import { RootProvider } from 'fumadocs-ui/provider/';
import type { ReactNode } from 'react';
import { SearchDialog } from '@/components/my-search-dialog';
export default function Layout({ children }: { children: ReactNode }) {
return (
{children}
);
}
```
Hot Keys [#hot-keys]
Customise the hot keys to trigger search dialog, by default it's ⌘K or CtrlK.
```tsx
import { RootProvider } from 'fumadocs-ui/provider/';
{children}
;
```
References [#references]
A full list of options.
| undefined",
"simplifiedType": "Partial