Manual Installation
Add Fumadocs to an existing TanStack Start project.
You can also let Fumadocs CLI set it up for you:
npx @fumadocs/cli initPrerequisites
Before continuing, make sure you have configured:
- Tailwind CSS 4.
- Fumadocs MDX: follow the Vite setup guide and create essential files like
lib/source.ts.
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-uiStyles
Add the following to your Tailwind CSS file:
@import 'tailwindcss';
@import 'fumadocs-ui/css/neutral.css';
@import 'fumadocs-ui/css/preset.css';Root Provider
Wrap your entire app inside Root Provider, and add the required styles to body.
import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router';
import * as React from 'react';
import { RootProvider } from 'fumadocs-ui/provider/tanstack';
export const Route = createRootRoute({
component: RootComponent,
});
function RootComponent() {
return (
<RootDocument>
<Outlet />
</RootDocument>
);
}
function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html suppressHydrationWarning>
<head>
<HeadContent />
</head>
<body className="flex flex-col min-h-screen">
<RootProvider>{children}</RootProvider>
<Scripts />
</body>
</html>
);
}Routes
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:
---
title: Hello World
---
## Introduction
I love Fumadocs.How is this guide?
Last updated on
