Fumadocs rebuilt on Hamur, the original is fumadocs.dev
Skip to Content
Fumadocs

Manual Installation

Add Fumadocs to an existing Next.js project.

You can also let Fumadocs CLI set it up for you:

npx @fumadocs/cli init

Prerequisites

Before continuing, make sure you have configured:

  • Next.js 16.
  • Tailwind CSS 4.

This guide uses Fumadocs MDX as the content source. Configure it first:

Installation

npm i fumadocs-mdx fumadocs-core @types/mdx

Add the plugin to Next.js config:

next.config.mjs
import { createMDX } from 'fumadocs-mdx/next';

/** @type {import('next').NextConfig} */
const config = {
  reactStrictMode: true,
};

const withMDX = createMDX();

export default withMDX(config);

ESM Only

Fumadocs MDX is ESM-only, it's recommended to use next.config.mjs for accurate ESM resolution.

For TypeScript config file, it requires Native Node.js TypeScript Resolver, you can see Next.js docs for details.

Integrate with Fumadocs

Create a lib/source.ts file:

lib/source.ts
import { defineDocs } from 'fumadocs-mdx/macro';
import { loader } from 'fumadocs-core/source';

const docs = defineDocs({
  dir: 'content/docs',
});

export const source = loader({
  baseUrl: '/docs',
  source: docs.toFumadocsSource(),
});

Done

You can now write content in content/docs folder.

Good to Know

Fumadocs also supports other content sources, including Content Collections and headless CMS.

Getting Started

Install the packages:

npm i fumadocs-core fumadocs-ui@npm:@fumadocs/base-ui

Like the templates, the command installs fumadocs-ui as an alias of @fumadocs/base-ui, the Base UI version of Fumadocs UI. For Radix UI, install fumadocs-ui without the alias.

Styles

Add the following to your Tailwind CSS file:

@import 'tailwindcss';
@import 'fumadocs-ui/css/neutral.css';
@import 'fumadocs-ui/css/preset.css';

Fumadocs UI has no default font. Pick one from next/font.

Root Provider

Wrap your entire app inside Root Provider, and add the required styles to body.

app/layout.tsx
import { RootProvider } from 'fumadocs-ui/provider/next';
import type { ReactNode } from 'react';

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <body
        // required styles
        className="flex flex-col min-h-screen"
      >
        <RootProvider>{children}</RootProvider>
      </body>
    </html>
  );
}

Routes

Put the shared options of your layouts in one file:

lib/layout.shared.tsx
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';

export function baseOptions(): BaseLayoutProps {
  return {
    nav: {
      title: 'My App',
    },
  };
}

Create the following files:

import defaultMdxComponents from 'fumadocs-ui/mdx';
import type { MDXComponents } from 'mdx/types';

export function getMDXComponents(components?: MDXComponents) {
  return {
    ...defaultMdxComponents,
    ...components,
  } satisfies MDXComponents;
}

export const useMDXComponents = getMDXComponents;

declare global {
  type MDXProvidedComponents = ReturnType<typeof getMDXComponents>;
}

The search route uses ZBSearch. See Document Search to configure it.

Finish

Start the dev server and write your docs in content/docs:

content/docs/index.mdx
---
title: Hello World
---

## Introduction

I love Fumadocs.

How is this guide?

Last updated on