Configuration File
The Fumadocs CLI uses acli.json configuration file to manage paths, aliases, and project settings.
Location
By default, the CLI looks forcli.json in the current directory. You can specify a custom location:
Creating a Configuration
Initialize a new configuration file:cli.json with defaults based on your project structure.
Configuration Schema
The CLI configuration supports the following options:$schema
Type: string
Description: JSON Schema reference for IDE autocomplete and validation.
Auto-generated based on project structure:
- With
srcdirectory:node_modules/@fumadocs/cli/dist/schema/src.json - Without
srcdirectory:node_modules/@fumadocs/cli/dist/schema/default.json
baseDir
Type: string
Default: "" (root) or "src" (if src directory detected)
Description: Base directory for your project files. All component paths are resolved relative to this directory.
aliases
Type: object
Description: Configure where different types of files are installed.
aliases.uiDir
Type: string
Default: "./components/ui"
Description: Directory for UI components (e.g., buttons, cards, dialogs).
aliases.componentsDir
Type: string
Default: "./components"
Description: Directory for regular components and blocks.
aliases.blockDir
Type: string
Default: "./components"
Description: Directory for block components (larger, composed components).
aliases.cssDir
Type: string
Default: "./styles"
Description: Directory for CSS and style files.
aliases.libDir
Type: string
Default: "./lib"
Description: Directory for utility functions and helper libraries.
uiLibrary
Type: "radix-ui" | "base-ui"
Default: "radix-ui"
Description: Which UI component library to use for Fumadocs UI components.
- Radix UI
- Base UI
Registry:
fumadocs/radix-uiDescription: Uses Radix UI primitives for accessible, unstyled components.Best for: Projects already using Radix UI or those wanting maximum accessibility.commands
Type: object
Description: Configure CLI command behavior and post-processing.
commands.format
Type: string (optional)
Description: Command to run for formatting generated code automatically after installation.
The format command receives the file path as an argument automatically.
Complete Configuration Examples
Default Configuration
Generated for projects without asrc directory:
cli.json
Source Directory Configuration
Generated for projects with asrc directory:
cli.json
Custom Configuration
Example with custom paths and formatters:cli.json
Monorepo Configuration
Example for a monorepo package:packages/docs/cli.json
Path Resolution
How Paths Work
The CLI resolves component installation paths using this formula:button component:
Relative vs Absolute Paths
All alias paths should be relative (starting with./):
Component Type Mapping
Components are installed to different directories based on their type:| Component Type | Alias | Example |
|---|---|---|
ui | uiDir | components/ui/button.tsx |
components | componentsDir | components/search.tsx |
block | blockDir | components/hero.tsx |
lib | libDir | lib/utils.ts |
css | cssDir | styles/globals.css |
route | baseDir | app/api/search/route.ts |
IDE Integration
VS Code
The$schema field enables autocomplete and validation in VS Code:
- Open
cli.jsonin VS Code - Start typing to see autocomplete suggestions
- Hover over fields for documentation
- Get instant validation for invalid values
TypeScript Path Aliases
Ensure yourtsconfig.json paths match your CLI configuration:
tsconfig.json
Environment Detection
The CLI automatically detects your project structure:src Directory Detection
When you run npx fumadocs, the CLI:
- Checks if a
srcdirectory exists - Sets
baseDirto"src"if found,""otherwise - Uses the appropriate schema reference
Package Manager Detection
The CLI automatically detects your package manager for dependency installation:- Checks for
pnpm-lock.yaml→ usespnpm - Checks for
yarn.lock→ usesyarn - Checks for
package-lock.json→ usesnpm - Defaults to
npmif none found
Migration Guide
Changing baseDir
If you need to move from a root-level to src-based structure:
Switching UI Libraries
To switch from Radix UI to Base UI (or vice versa):Troubleshooting
Components installed to wrong directory
Components installed to wrong directory
Problem: Components are being installed to unexpected locations.Solution: Check your
baseDir and alias configuration:Schema validation errors
Schema validation errors
Problem: VS Code shows errors in
cli.json.Solution: Ensure your schema reference matches your project structure:Import path mismatches
Import path mismatches
Problem: TypeScript can’t find imported components.Solution: Ensure
tsconfig.json paths match CLI aliases:tsconfig.json
Format command not running
Format command not running
Problem: Code isn’t being formatted after installation.Solution: Ensure the format command is installed and accessible:
Best Practices
Version control
Always commit
cli.json to ensure consistent component paths across your team.Match TypeScript paths
Keep
tsconfig.json paths in sync with CLI aliases to avoid import errors.Use auto-formatting
Configure
commands.format to maintain consistent code style automatically.Document customizations
Add comments to explain non-standard alias configurations for team members.