Fumadocs
Powering your current documentation reading experience. No further explanation needed.
Fumadocs
Modern documentation site building framework compatible with Next.js 14 App Router.
MDX
Markdown extended with YAML and JSX to create supercharged content.
Installation
Follow the prompt with the responses.
You should see:
Navigate to the localhost url in your browser to see the app running. You can also ⌘+Click or Ctrl+Click it.
If you have other servers running locally, it may be on a different port than 3000 and that's okay.
Migrate project to use 'src' directory
As the time of writing this, Fumadocs creates a Next.js app with the app directory at the root level, and does not provide the option to use the src directory, which would be provided by the Next.js CLI.
Therefore, we need to manually move the app directory into the src directory, and then make some pathing changes in various files.
Create a src directory at the root level, and move the app and content directories into it.
Now see the After tab.
Fix Broken Paths
If you try to run the app, you'll see that it doesn't work. This is because the paths in the tsconfig.json, tailwind.config.js, route.ts, app/page.tsx, layout.config.tsx, source.ts, and next.config.mjs files are still pointing to the app and content directories at the root level. Let's fix them.
Run the app again, everything should be working now.
Configuration
Add Theme Presets
Easily see the UI differences between the home route and the docs route. Use whichever one you prefer, this one uses purple.
Document CSS Variables for future reference & customization
Navbar GitHub Link
Add Header
The properties currently accepted by the Docs Layout can be accepted by the Home layout as well.
For the header to appear, the DocsLayout component needs to be wrapped in the HomeLayout component.
At this point the header should appear on the docs site. However, it contains many of the same elements as the sidebar, such as the title, search bar, theme toggle, links, etc.
Unfortunately, Fumadocs does not provide a way to customize the header(HomeLayout) and sidebar(DocsLayout) separately through a clean API due to opinion. Therefore we have to target the CSS classes directly to conditionally render them at different screen sizes.
Customize Header
Add Package Install plugin
Add Remark plugin with custom Tabs configuration
Add Tabs configuration to mdx-components.tsx. Whichever tab the user chooses will persist, even if they navigate to another page.
Add Lucide React Icons
Add finder function to loader
This allows us to use icons in docs without importing them.
Use Icons in Docs
You can now use Lucide React icons in your docs.
Define Pages
Use a pages variable for single source of truth.
You can import these pages in .mdx files and use them like this:
As of right now, I haven't been able to get path aliasing to work, hence the spaghetti import.
The url property must be specified in that format, otherwise RootToggle will not change options when clicked.
Add Root Toggle button
The url property must be specified in that format, otherwise RootToggle will not change options when clicked.
Add Roll Button
Add the button you currently see that scrolls to the top when clicked.
The button is hidden behind the desktop header. Apply the following CSS to make it visible.
Add Steps
Add 'Last updated' time to footer
Render page descriptions under title
Add 'Edit on GitHub' button
Use repository URL in package.json as source.
Create button.
Create Custom MDX Component for Index Page Cards
As of writing, Fumadocs has no API to autogenerate index page cards, so create it.
Add Favicon and Icon
Create a public/ directory at the root level to store static assets.
I use convert.io to convert SVGs into favicons.
Paste the favicon.ico and icon.ico files in the app, (home), and docs directories. As of right now I'm not sure which one it was that made it work.
Last updated on