Getting Started
Learn how to use Fumadocs MDX in your documentation
Introduction
fumadocs-mdx
is a Next.js plugin that enhances the experience of the official
next/mdx
package. It parses frontmatter and is bundled with several MDX
plugins for building a good documentation site.
This package must be used with Fumadocs
Usage
Install Dependencies
Configuration
Add this to your next.config.mjs
file:
The Next.js config must be a .mjs
file since it requires ESM-only modules.
Define MDX Components
Create mdx-components.tsx
in your root directory.
Resolve Files
It automatically generates a .map.ts
file once you start the dev server or start building the app.
The raw data of pages is stored in the map
property from your .map.ts
file. To Integrate with Source API, create a source.ts
file, and define the source with createMDXSource
which returns a
Page Tree and additional utilities.
Read Pages Conventions to learn how to structure your pages.
Start Server
Start the dev server
A .map.ts
file should be created. You can log and see if it is loaded correctly.
Built-in Features
Frontmatter (frontmatter
), Table of Contents (toc
) and Structurized Data (structuredData
) are parsed
and exported from MDX files by default, you can use these for implementing a
search or TOC section in your docs.
Advanced Usages
Multiple Types
You can have multiple document types, such as blog posts, or documents. By
passing the rootDir
option, the resolved files will be restricted within a
specified folder.
MDX Plugins
You can customise the options passed to the MDX processor.
Export Properties from vfile.data
The built-in configuration applies a remark plugin that turns vfile.data
properties into exports, you can define additional properties to be exported.
Last updated on