Getting Started
Learn how to use Fumadocs MDX in your documentation
Introduction
fumadocs-mdx
is the official content source of Fumadocs. It parses frontmatter and is bundled with many MDX
plugins for building a good documentation site.
This package must be used with Fumadocs
Getting Started
Install Dependencies
Configuration
Add the plugin to your next.config.mjs
file.
It generates a .map.ts
file once you start the dev server or start building the app.
The map file contains all parsed files, you should add it to .gitignore
.
ESM Only
The Next.js config must be a .mjs
file since Fumadocs is ESM-only.
Define MDX Components
Create mdx-components.tsx
in your root directory.
Resolve Files
To integrate with Fumadocs, create:
For more customisation options, check Source API.
Start Server
A .map.ts
file should be created. You can log and see if it is loaded correctly.
See Pages Conventions to learn how to organize your pages.
FAQ
Built-in Properties
These properties are exported from MDX files by default.
Property | Description |
---|---|
frontmatter | Frontmatter |
toc | Table of Contents |
structuredData | Structured Data, useful for implementing search |
MDX Plugins
You can customise the options passed to the MDX processor.
See Configuration to learn more.
What is the .map
file?
The .map
file is generated by our Webpack plugin in build time.
It includes the information of files under your content directory,
which can be access by your Next.js app to implement SSG and many other features.
Deep Dive
How does it work?
Fumadocs MDX is a webpack plugin over Next.js to support reading/importing a MDX file by its name. Because Next.js could only optimize static imports, it first generates a map file that imports all supported files under the root directory.
The imported files form an array called map
in your .map.ts
file, so that your Next.js app can access them without manually importing all of them.
Last updated on