Prerequisites
Before you begin, ensure you have:- Node.js 18+ installed
- A Next.js 16 application with Tailwind CSS 4
- Basic familiarity with React and MDX
Installation
Install Fumadocs Packages
Install the core Fumadocs packages:- fumadocs-ui: Pre-built UI components and layouts
- fumadocs-core: Core functionality for loading and managing docs
- fumadocs-mdx: MDX content source integration
Configure Fumadocs MDX
Create asource.config.ts file in your project root:source.config.ts
content/docs directory.Set Up Root Layout
Wrap your application with the Root Provider inapp/layout.tsx:app/layout.tsx
suppressHydrationWarning prop is needed for theme support, and the flex classes ensure proper layout.Add Fumadocs Styles
Import Fumadocs CSS in yourglobal.css:app/globals.css
- Tailwind CSS base styles
- Fumadocs neutral theme (you can choose other themes)
- Fumadocs preset with utilities and components
Create Source Loader
Createlib/source.ts to load your documentation:lib/source.ts
loader function creates a source object that provides methods to access your documentation pages and generate navigation.Configure MDX Components
Createmdx-components.tsx in your root directory:mdx-components.tsx
Create Shared Layout Options
Createlib/layout.shared.tsx for reusable layout configuration:lib/layout.shared.tsx
Set Up Docs Layout
Create the docs layout atapp/docs/layout.tsx:app/docs/layout.tsx
DocsLayout component provides:- Sidebar navigation with collapsible sections
- Table of contents
- Breadcrumbs
- Theme switcher
Create Dynamic Page Route
Createapp/docs/[[...slug]]/page.tsx for rendering documentation pages:app/docs/[[...slug]]/page.tsx
Create Your First MDX Page
Create your first documentation page atcontent/docs/index.mdx:content/docs/index.mdx
Start Development Server
Run your development server:http://localhost:3000/docs to see your first documentation page!Understanding the Structure
File-Based Routing
Fumadocs uses file-based routing. Your file structure incontent/docs/ directly maps to URL paths:
Frontmatter
Every MDX file should include frontmatter with metadata:- title: Page title (required)
- description: SEO description
- icon: Icon from lucide-react
- full: Whether to use full-width layout
Built-in Components
Fumadocs provides many built-in components:- Callouts - Highlight important information with different styles (info, warning, tip, danger)
- Tabs - Organize content with tabbed interfaces for package managers or code examples
- Steps - Create sequential instructions with numbered steps
- Cards - Display feature grids and navigation links
- Code Blocks - Syntax-highlighted code with copy buttons and line numbers
Adding More Pages
To add more documentation pages, simply create new MDX files:content/docs/getting-started.mdx
Usage
Import and use:Next Steps
Now that you have your first documentation page:- Customize the theme to match your brand
- Add search functionality for better discoverability
- Set up multiple docs for different products
Troubleshooting
Page Not Found
If your page shows 404:- Check that the MDX file exists in
content/docs/ - Verify frontmatter includes
title - Restart the dev server
Styles Not Loading
If styles aren’t working:- Ensure you imported Fumadocs CSS in
global.css - Check that Tailwind CSS 4 is properly configured
- Verify the
className="flex flex-col min-h-screen"is on thebodytag
Components Not Rendering
If MDX components don’t work:- Verify
mdx-components.tsxexists in the root - Check that you’re passing
getMDXComponents()to theMDXcomponent - Import any custom components explicitly