Fumadocs CLI
Using the Fumadocs CLI for enhanced documentation management and components
Fumadocs CLI
The Fumadocs CLI is a powerful tool for managing and enhancing your documentation site with components, customizations, and file tree generation.
Installation
Initialize a config for CLI:
npx @fumadocs/clipnpm dlx @fumadocs/cliyarn dlx @fumadocs/clibun x @fumadocs/cliYou can change the output paths of components in the config.
Components
Install Components Interactively
npx @fumadocs/cli addpnpm dlx @fumadocs/cli addyarn dlx @fumadocs/cli addbun x @fumadocs/cli addInstall Specific Components
# Install banner and files components
npx @fumadocs/cli add banner files
# Install individual components
npx @fumadocs/cli add banner
npx @fumadocs/cli add files
npx @fumadocs/cli add tabsAvailable Components
Common components you can add:
- banner - Page banners and notifications
- files - File tree visualization
- tabs - Tabbed content sections
- cards - Card layouts for content
- callouts - Highlighted information boxes
How It Works
The CLI fetches the latest version of components directly from the Fumadocs GitHub repository, ensuring you always get up-to-date components. It also automatically transforms import paths to match your project structure.
Note: Make sure to use the latest version of the CLI for best compatibility.
Customization
Customize Layouts
# Interactive customization
npx @fumadocs/cli customiseThis provides a simple way to customize Fumadocs layouts without manually editing configuration files.
File Tree Generation
Generate File Trees
The CLI can generate file tree components using your actual directory structure:
# Generate TypeScript component
npx @fumadocs/cli tree ./my-dir ./output.tsx
# Generate MDX file
npx @fumadocs/cli tree ./my-dir ./output.mdx
# Get help for tree command
npx @fumadocs/cli tree -hExample Output
When you run the tree command on a directory, it generates a component like this:
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>
);Practical Examples
Adding a Banner Component
-
Install the banner component:
npx @fumadocs/cli add banner -
Use in your documentation:
import { Banner } from '@/components/ui/banner'; <Banner type="warning"> This feature is in beta. Use with caution in production. </Banner>
Creating File Trees for Documentation
-
Generate a file tree for your project structure:
npx @fumadocs/cli tree ./src ./components/project-structure.tsx -
Include in your documentation:
import ProjectStructure from '@/components/project-structure'; ## Project Structure <ProjectStructure />
Documenting Docker Project Structure
# Generate file tree for a Docker project
npx @fumadocs/cli tree ./docker-project ./components/docker-structure.mdxThis might generate:
import { File, Folder, Files } from 'fumadocs-ui/components/files';
<Files>
<Folder name="docker-project">
<File name="Dockerfile" />
<File name="docker-compose.yml" />
<File name="docker-compose.prod.yml" />
<Folder name="nginx">
<File name="nginx.conf" />
<File name="Dockerfile" />
</Folder>
<Folder name="app">
<File name="package.json" />
<File name="server.js" />
</Folder>
<File name=".dockerignore" />
</Folder>
</Files>Integration with N-Docs
Enhancing Documentation Pages
You can use the CLI to add components that enhance your existing documentation:
- Add file trees to show project structures
- Add banners for important notices
- Add tabs for multi-language examples
- Add cards for feature showcases
Example: Enhanced Docker Documentation
---
title: Docker Project Structure
---
import { Banner } from '@/components/ui/banner';
import { Files, File, Folder } from 'fumadocs-ui/components/files';
# Docker Project Structure
<Banner type="info">
This guide shows recommended Docker project organization.
</Banner>
## Recommended Structure
<Files>
<Folder name="my-docker-app">
<File name="Dockerfile" />
<File name="docker-compose.yml" />
<File name="docker-compose.prod.yml" />
<File name=".dockerignore" />
<Folder name="src">
<File name="app.js" />
<File name="package.json" />
</Folder>
<Folder name="nginx">
<File name="nginx.conf" />
<File name="Dockerfile" />
</Folder>
<Folder name="scripts">
<File name="deploy.sh" />
<File name="backup.sh" />
</Folder>
</Folder>
</Files>CLI Commands Reference
# Initialize configuration
npx @fumadocs/cli
# Add components interactively
npx @fumadocs/cli add
# Add specific components
npx @fumadocs/cli add [component-names...]
# Customize layouts
npx @fumadocs/cli customise
# Generate file tree
npx @fumadocs/cli tree [input-dir] [output-file]
# Get help
npx @fumadocs/cli --help
npx @fumadocs/cli tree --helpWhat's Next?
- Fumadocs Setup - Learn how to set up Fumadocs from scratch
- Official Fumadocs Docs - Explore available components
- Component Examples - See components in action
The Fumadocs CLI makes it easy to keep your documentation visually appealing and well-organized with minimal effort!