User Guide
The CLI tool that automates setups and installs components.
Installation
Initialize a config for CLI:
npx @fumadocs/cliYou can change the output paths of components in the config.
Init
Set up Fumadocs on an existing app, it supports Next.js, React Router, Tanstack Start and Waku.
npx @fumadocs/cli initTo avoid conflicts with your app, the docs pages are added in a dedicated route group (e.g. app/(docs) on Next.js) with their own provider and layout, route handlers like the search API follow the examples. Only a few edits are made to existing files:
- Fumadocs MDX plugin in your framework config.
- Fumadocs UI styles in your global CSS.
suppressHydrationWarningon the<html>element of your root layout, for the theme switch..sourcein.gitignore.
Pass --i18n to set up internationalization: the docs routes get a locale segment (optional for the default locale where the router supports it), a lib/i18n.ts config and, on Next.js, a proxy scoped to the docs routes. Other features follow the i18n config of your project.
It asks before overwriting a file, pass --yes to skip prompts and --no-install to only write dependencies to package.json.
Features
Configure a feature on your project, it installs the needed components & routes, and wires them into your app.
npx @fumadocs/cli feature ai --provider openrouter| Feature | Description |
|---|---|
docs | Set up Fumadocs, same as init. |
ai | Ask AI dialog, --provider. |
llms | LLM routes: llms.txt, llms-full.txt and per-page Markdown. |
mcp | MCP server to search and read the docs. |
webmcp | WebMCP tools for AI agents in the browser, experimental. |
og | Open Graph image generation, --engine. |
search | 3rd party search solution, --provider. |
feedback | Feedback component on docs pages. |
epub | Route to export EPUB. |
lint | Configure ESLint (Next.js only), Biome or Oxlint, --linter. |
Features adapt to your setup:
- Fumadocs MDX with the Macro API or a
source.config.ts, other content sources can't usellms,mcpandepub. - The
baseUrlof your docs,src/directory,next.config.ts, i18n, static export and SPA modes. - React Router with file-based routes: the routes to register are printed instead.
The paths of routes are placed under the constants of lib/shared.ts.
See help for the available options:
npx @fumadocs/cli feature -hComponents
Select and install components.
npx @fumadocs/cli addYou can pass component names directly.
npx @fumadocs/cli add banner filesHow 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.
Customize
A simple way to customize Fumadocs layouts.
npx @fumadocs/cli customizeIt installs the layout into layouts and points the imports of your route files at it.
Shadcn UI
On projects with a components.json, the CLI follows the aliases of Shadcn UI and:
- installs the
shadcnpreset, so Fumadocs UI adopts your theme colors. - reuses the
button,popoverandcollapsiblein youruidirectory, they share the API of Shadcn UI. - imports
cnfrom yourutilsalias.
Fumadocs' copies are only installed when you don't have them yet.
Tree
Generate files tree for Fumadocs UI Files component, using the tree command from your terminal.
npx @fumadocs/cli tree ./my-dir ./output.tsxYou can output MDX files too:
npx @fumadocs/cli tree ./my-dir ./output.mdxSee help for further details:
npx @fumadocs/cli tree -hExample Output
import { File, Folder, Files } from 'fumadocs-ui/components/files';
export default (
<Files>
<Folder name="app">
<File name="layout.tsx" />
<File name="page.tsx" />
<File name="global.css" />
</Folder>
<Folder name="components">
<File name="button.tsx" />
<File name="tabs.tsx" />
<File name="dialog.tsx" />
</Folder>
<File name="package.json" />
</Files>
);How is this guide?
Last updated on
