Relevant source files
The following files were used as context for generating this wiki page:
- packages/core/package.json
- packages/preview/package.json
- packages/api-docs/package.json
- packages/content/src/index.ts
- packages/python/package.json
- packages/basehub/package.json
- packages/openapi/package.json
- packages/local-md/package.json
- packages/content/package.json
- packages/mdx/src/runtime/dynamic.ts
- packages/preview/src/pages/...slugs.tsx
- packages/base-ui/package.json
- packages/content/src/runtime.ts
- packages/epub/package.json
- packages/obsidian/package.json
- packages/radix-ui/package.json
- packages/cli/src/commands/shared.ts
- packages/typescript/package.json
- packages/shared/package.json
- packages/cli/src/index.ts
- packages/twoslash/package.json
- packages/doc-gen/package.json
- packages/mdx/src/runtime/server.ts
- packages/asyncapi/package.json
- packages/create-app/package.json
- packages/sanity/registry/index.ts
- packages/story/package.json
- packages/mdx/package.json
- packages/python/pyproject.toml
- packages/preview/fumadocs.config.ts
Overview
Fumadocs is a modern, framework-agnostic documentation ecosystem designed for React applications, providing a modular architecture that separates core document processing, source loading, and layout presentation packages/core/package.json:2-4. It addresses the complexity of building documentation sites by decoupling headless primitives and build-time content compilation from opinionated styling layers and frontend frameworks. The project is organized as a monorepo workspace containing runtime engines, bundler integration plugins, and user interface implementations [packages/core/package.json:2-4, packages/radix-ui/package.json:2-4. Fumadocs integrates closely with tools like BaseHub Integration and MDX Runtime Compilation to support flexible content workflows and dynamic rendering [packages/basehub/package.json:4-4, packages/mdx/src/runtime/server.ts:1-2.
Architecture and Design Philosophy
Fumadocs is architected around a strict separation of concerns, decoupling framework-agnostic document processing, source loading, and state management from concrete UI implementations packages/core/package.json:2-4. The core runtime library (fumadocs-core) delivers navigation tree generation, internationalization negotiation, search server indexing, syntax highlighting, and remark/rehype markdown AST transformations without depending on a specific frontend framework or bundler [packages/core/package.json:2-4, packages/core/package.json:42-87.
The ecosystem provides explicit framework routing adapters and runtime provider packages for Next.js, React Router, TanStack, Waku, and Vite [packages/core/package.json:29-33, packages/radix-ui/package.json:104-108. This modular layer separation allows documentation content models and source schemas to be compiled independently of presentation components, which are supplied separately through accessible UI packages like fumadocs-ui backed by Radix UI primitives [packages/radix-ui/package.json:2-4, packages/radix-ui/package.json:134-143.
| Layer Category | Primary Package | Export Modules & Target Responsibilities |
|---|---|---|
| Core Engine | fumadocs-core | ./source, ./page-tree, ./i18n, ./search, ./highlight, ./mdx-plugins |
| Content Compilation | fumadocs-mdx | ./node, ./vite, ./next, ./rolldown, ./webpack/mdx, ./runtime/server |
| UI & Layouts | fumadocs-ui | ./layouts/docs, ./layouts/flux, ./components/codeblock, ./components/dialog/search |
| Content Adapter | @fumadocs/content | . (index), ./runtime for standard-schema type-safe document fetching |
| Shared Utilities | shared | Internal helper workspace for CLI tooling, translation specs, and glob file scanning |
Sources: packages/core/package.json:20-88, packages/content/package.json:17-21, packages/radix-ui/package.json:18-117, packages/shared/package.json:4-8, packages/mdx/package.json:24-44
Note
The @fumadocs/content adapter depends on @standard-schema/spec and fuma-content to decouple validation schemas from specific file-system loaders [packages/content/package.json:32-34, packages/content/package.json:43-46.
Sources: packages/content/package.json:32-46
Important
Framework integration is completely decoupled via dedicated export entry points in fumadocs-core (such as ./framework/next, ./framework/react-router, ./framework/tanstack, and ./framework/waku), preventing runtime coupling to Next.js packages/core/package.json:29-33.
Sources: packages/core/package.json:29-33
Monorepo Package Structure and Roles
Core Runtime and Content Compilers
The Fumadocs workspace organizes its source code into specialized packages, separating the framework-agnostic runtime engine from build-time content compilation and UI layers. The core runtime package, fumadocs-core, provides foundational services including source file discovery, page tree calculations, internationalization negotiation, search server indexing, syntax highlighting, and unified remark/rehype markdown AST transformations packages/core/package.json:2-4, packages/core/package.json:42-87.
Build-time processing is handled by fumadocs-mdx, which exposes integration entry points for bundlers and runtime loaders, including Next.js, Vite, Webpack, Rolldown, and Bun packages/mdx/package.json:24-44. Content validation and schema mapping across standard schemas are delegated to @fumadocs/content, which relies on fuma-content and @standard-schema/spec packages/content/package.json:32-46.
Sources: packages/core/package.json:2-4, packages/core/package.json:42-87, packages/mdx/package.json:24-44, packages/content/package.json:32-46
Important
The fumadocs-mdx package maintains separate sub-exports for static node compilation (./node, ./node/loader) and client/server runtimes (./runtime/server, ./runtime/browser, ./runtime/dynamic), preventing server-only modules from leaking into browser bundles packages/mdx/package.json:24-44.
Sources: packages/mdx/package.json:24-44
UI Implementations and Layouts
Presentation components are factored into distinct UI packages that target specific primitive ecosystems. The two primary UI design implementations are fumadocs-ui (backed by Radix UI primitives) and @fumadocs/base-ui (built for Base UI) packages/base-ui/package.json:2-4, packages/radix-ui/package.json:2-4, packages/cli/src/commands/shared.ts:1-4. Both packages provide identical export paths for documentation layouts, navigation slots, code blocks, search dialogs, and interactive UI widgets packages/base-ui/package.json:18-114, packages/radix-ui/package.json:18-117.
| Package Name | Primary Dependency Stack | Target UI Library & Layout Exports |
|---|---|---|
fumadocs-ui (radix-ui) | Radix Primitives (@radix-ui/react-*), motion, next-themes | ./layouts/docs, ./layouts/flux, ./layouts/notebook, ./layouts/home packages/radix-ui/package.json:58-90, packages/radix-ui/package.json:134-153 |
@fumadocs/base-ui | Base UI primitives, motion, next-themes | ./layouts/docs, ./layouts/flux, ./layouts/notebook, ./layouts/home packages/base-ui/package.json:58-90 |
@fumadocs/api-docs | Radix Accordion/Dialog/Select, @fumari/stf | ./schema, ./codegen, ./components/schema, ./components/dialog packages/api-docs/package.json:18-42, packages/api-docs/package.json:56-67 |
Sources: packages/base-ui/package.json:18-114, packages/radix-ui/package.json:18-117, packages/api-docs/package.json:18-67, packages/cli/src/commands/shared.ts:1-4]
Note
The CLI utility references UI registries via the configuration mapping in UIRegistries, associating 'base-ui' with fumadocs/base-ui and 'radix-ui' with fumadocs/radix-ui packages/cli/src/commands/shared.ts:1-4.
Sources: packages/cli/src/commands/shared.ts:1-4
Tooling, Extensibility, and Preview Packages
Specialized plugins and developer tooling are isolated into independent workspace packages to keep runtime footprints minimal packages/preview/package.json:2-4, packages/typescript/package.json:2-4, packages/twoslash/package.json:2-4, packages/doc-gen/package.json:2-4, packages/create-app/package.json:2-4. These include fumadocs-typescript for type table extractions via ts-morph packages/typescript/package.json:39-49, fumadocs-twoslash for Shiki-based compiler diagnostics packages/twoslash/package.json:45-53, fumadocs-docgen for remark utilities like remark-ts2js packages/doc-gen/package.json:26-30, packages/doc-gen/package.json:41-50, fumadocs-preview for Waku-backed fast content previews with AI search features packages/preview/package.json:2-4, packages/preview/package.json:35-88, and create-fumadocs-app for project scaffolding packages/create-app/package.json:2-4, packages/create-app/package.json:43-52.
Sources: packages/preview/package.json:2-4, packages/preview/package.json:35-88, packages/typescript/package.json:2-4, packages/typescript/package.json:39-49, packages/twoslash/package.json:2-4, packages/twoslash/package.json:45-53, packages/doc-gen/package.json:2-4, packages/doc-gen/package.json:26-30, packages/doc-gen/package.json:41-50, packages/create-app/package.json:2-4, packages/create-app/package.json:43-52
Content Compilation and Source Processing
Document Schemas and Collection Configuration
Document parsing and type-safe frontmatter validation rely on @standard-schema/spec [packages/content/package.json:32-34, packages/mdx/package.json:56-58]. The @fumadocs/content package provides helper utilities like docsMdxCollection and docsCollection to structure directories containing MDX documents and metadata files packages/content/src/index.ts:16-53. By default, docsMdxCollection integrates mdxPreset configurations with remark include plugins for content composition packages/content/src/index.ts:24-32.
Sources: packages/content/package.json:32-34, packages/content/src/index.ts:16-53, packages/mdx/package.json:56-58]
Note
The docsMdxCollection builder automatically falls back to pageSchema for frontmatter validation when a custom schema is omitted packages/content/src/index.ts:16-19.
Sources: packages/content/src/index.ts:16-19]
Runtime and Dynamic MDX Compilation
The fumadocs-mdx package supports runtime compilation and dynamic execution of MDX files through its runtime modules [packages/mdx/package.json:37-40]. The dynamic utility resolves collections and compiles raw content entries into hydrated properties packages/mdx/src/runtime/dynamic.ts:47-95.
async function executeMdx(compiled: string, options: ExecuteOptions = {}) {
const { opts: scopeOpts, ...scope } = options.scope ?? {};
const fullScope = {
opts: {
...(scopeOpts as object),
...(options.jsxRuntime ?? jsxRuntimeDefault),
baseUrl: options.baseUrl,
},
...scope,
};
const hydrateFn = new AsyncFunction(...Object.keys(fullScope), compiled);
return await hydrateFn.apply(hydrateFn, Object.values(fullScope));
}Sources: packages/mdx/src/runtime/dynamic.ts:32-45]
The DocsCollection class manages code generation by listening to emission hooks and constructing virtual code modules that link back to stores packages/content/src/index.ts:55-70. Concurrently, toFumadocsSource maps underlying file collection stores into structured static sources containing page and metadata entries packages/content/src/runtime.ts:12-42.
Sources: packages/content/src/index.ts:55-70, packages/content/src/runtime.ts:12-42]
Presentation Primitives and Layout Systems
Headless UI Implementations and UI Registries
Fumadocs separates visual styling and component layout architectures into two alternative UI implementations: @fumadocs/base-ui and fumadocs-ui (backed by Radix UI primitives) packages/base-ui/package.json:2-4, packages/radix-ui/package.json:2-4. These UI variants share identical export paths for foundational primitives, layout slots, and navigation contexts while consuming distinct underlying primitives. The command line utility references these two packages under the identifiers base-ui and radix-ui packages/cli/src/commands/shared.ts:1-4.
| UI Package | Package Name | Registry Key | Primary Dependencies |
|---|---|---|---|
| Base UI Version | @fumadocs/base-ui | base-ui | Tailored base primitives and CSS exports |
| Radix UI Version | fumadocs-ui | radix-ui | @radix-ui/react-*, motion, next-themes |
Sources: packages/base-ui/package.json:2-4, packages/radix-ui/package.json:2-4, packages/cli/src/commands/shared.ts:1-4, packages/radix-ui/package.json:131-154]
Important
Both UI packages expose identical module entry points for layouts (./layouts/docs, ./layouts/flux, ./layouts/notebook, ./layouts/home), search dialogs, and component slots, enabling seamless switching between Radix and Base UI runtimes without altering layout consumption code packages/base-ui/package.json:18-114, packages/radix-ui/package.json:18-117.
Sources: packages/base-ui/package.json:18-114, packages/radix-ui/package.json:18-117]
Layout Presets and Markdown Compilation Pipeline
Layout presets determine how documentation pages and structural containers renderpackages/preview/src/pages/[...slugs].tsx:80-96. The preview server configuration supports dynamic markdown rendering pipelines incorporating remark and rehype plugins for math, headings, GFM, code tabs, package manager persistence, and Mermaid diagramspackages/preview/src/pages/[...slugs].tsx:29-46.
const compiler = createMarkdownCompiler({
remarkPlugins: [
remarkGfm,
remarkMath,
remarkMdxMermaid,
plugin(remarkHeading, { generateToc: false }),
plugin(remarkNpm, { persist: { id: 'package-manager' } }),
remarkCodeTab,
],
remarkRehypeOptions: {
passThrough: ['mdxJsxFlowElement', 'mdxJsxTextElement'],
},
rehypePlugins: [
rehypeKatex,
plugin(rehypeCode, { lazy: true, fallbackLanguage: 'text' }),
plugin(rehypeToc, { exportToc: { as: 'data' } }),
],
});Sources: packages/preview/src/pages/...slugs.tsx:29-46]
The dynamic page renderer inspects the layout preset configuration (docs or flux) to load corresponding layout modules and page components dynamicallypackages/preview/src/pages/[...slugs].tsx:80-96. When rendering documentation containers, AI search widgets are conditionally injected alongside layout slots if AI support is enabledpackages/preview/src/pages/[...slugs].tsx:113-138.
Sources: packages/preview/src/pages/...slugs.tsx:80-96, packages/preview/src/pages/...slugs.tsx:113-138]
Tooling and Extensibility Ecosystem
Specification Generators and Language Integration Plugins
Fumadocs provides specialized packages that ingest specification files and foreign source code, transforming them into documentation structures. The fumadocs-openapi package parses OpenAPI v3 and Swagger definitions to generate MDX documentation pages, client request generators, and interactive UI components, with exports for C#, cURL, Go, Java, JavaScript, and Python request generatorspackages/openapi/package.json:2-37. Similarly, @fumadocs/asyncapi processes AsyncAPI specifications to generate documentation for asynchronous message-driven architectures with dedicated server and internationalization entry pointspackages/asyncapi/package.json:2-25. For Python codebases, fumadocs-python and the underlying fumapy module inspect source code and docstrings using Griffe and Griffe typing extensions to extract API documentationpackages/python/package.json:2-4, packages/python/pyproject.toml:2-8.
| Tool / Plugin Package | Package Identifier | Primary Purpose | Key Export Endpoints |
|---|---|---|---|
| OpenAPI Generator | fumadocs-openapi | OpenAPI v3/Swagger MDX doc generation & request building | ., ./ui, ./scalar, ./requests/generators/* |
| AsyncAPI Generator | @fumadocs/asyncapi | AsyncAPI event-driven messaging documentation | ., ./ui, ./server, ./i18n |
| Python Docgen | fumadocs-python | Python docstring extraction and component presets | ., ./components, ./preset.css |
| Story Integration | @fumadocs/story | Component prop parsing and interactive playgrounds | ., ./next, ./vite, ./type-tree |
Sources: packages/python/package.json:2-32, packages/openapi/package.json:2-37, packages/asyncapi/package.json:2-25, packages/python/pyproject.toml:2-8, packages/story/package.json:2-24]
Note
The @fumadocs/story package supports multiple build systems and frameworks, offering dedicated entry points for Next.js (./next, ./next/client), Vite (./vite, ./vite/client), and Webpack (./webpack/story) alongside type-tree extractionpackages/story/package.json:14-24.
Sources: packages/story/package.json:14-24]
Standalone Content Sources and Export Utilities
Additional packages extend content ingestion and distribution capabilities beyond standard Markdown and MDX files. The @fumadocs/local-md package parses local Markdown files and executes embedded expressions in Node and browser runtimes, exposing execution targets such as executor, executor-native, and executor-virtualpackages/local-md/package.json:2-30. For offline reading, fumadocs-epub bundles compiled documentation pages, assets, and tables of contents into EPUB ebookspackages/epub/package.json:2-26. Integration with headless CMS platforms is supported by registry modules like fumadocs/sanity, which provides installable component snippets for rendering portable text collections packages/sanity/registry/index.ts:1-100.
Sources: packages/local-md/package.json:2-30, packages/epub/package.json:2-26, packages/sanity/registry/index.ts:1-100]
Developer CLI Workflows
The Fumadocs CLI (@fumadocs/cli) and site scaffolding tool (create-fumadocs-app) orchestrate project initialization, component management, and export actionspackages/cli/src/index.ts:1-116, packages/create-app/package.json:2-31. The CLI runner initializes configuration files, customizes UI layouts, downloads registry components via local or HTTP connectors, exports documentation to EPUB format, and converts file tree structures into JavaScript or MDX modulespackages/cli/src/index.ts:17-114.
program
.command('add')
.description('add a new component to your docs')
.argument('[components...]', 'components to download')
.option('--dir <string>', 'the root url or directory to resolve registry')
.action(async (input: string[], options: { config?: string; dir?: string }) => {
const config = await createOrLoadConfig(options.config);
const client = createClientFromDir(options.dir);
await add(input, client, config);
});
const exportCmd = program.command('export').description('export documentation to various formats');
exportCmd
.command('epub')
.description('export documentation to EPUB format (run after production build)')
.requiredOption('--framework <name>', 'React framework: next, tanstack-start, react-router, waku')
.option('--output <path>', 'output file path', 'docs.epub')
.option('--scaffold-only', 'only scaffold the EPUB route, do not copy')
.action(async (options: { output?: string; framework: string; scaffoldOnly?: boolean }) => {
await exportEpub({
output: options.output,
framework: options.framework,
scaffoldOnly: options.scaffoldOnly,
});
});Sources: packages/cli/src/index.ts:44-69]
Warning
The EPUB export command (fumadocs export epub) must be run after a successful production build, and requires specifying the target React framework via the required --framework optionpackages/cli/src/index.ts:57-69.
Sources: packages/cli/src/index.ts:57-69]
Where to go next
| I want to… | Read |
|---|---|
| How do you scaffold and run a minimal Fumadocs documentation site from scratch? | Quick Start |
| What are the responsibilities and dependencies across the packages in the Fumadocs workspace? | Project Structure |
| How does Fumadocs discover, parse, validate, and manage collections of documents and meta files into structured sources? | Source Loader |
| How are hierarchical navigation trees built, transformed, sorted, and decorated with status badges and icons? | Page Tree Generation |
| How are documents scanned, structured, and indexed on the server using Orama, Flexsearch, or Algolia engines? | Search Server Indexing |
| How do client dialogs query search backends including local endpoints, Orama Cloud, Algolia, and Mixedbread? | Search Client Integrations |
| How does Shiki integration format code blocks, manage themes, parse meta attributes, and handle transformer tokens? | Syntax Highlighting |
| What remark and rehype AST transformations occur for admonitions, headings, steps, LLM exports, and mermaid diagrams? | Markdown AST Plugins |
| How are framework-agnostic navigation, dynamic links, and router abstractions provided for Next.js, Vite, React Router, and Waku? | Framework Routing Adapters |
| How does Fumadocs handle locale switching, fallback languages, language negotiation, and translated page trees? | Internationalization Support |
| How does fumadocs-mdx compile MDX documents, track file metadata, and integrate with build tools via unified plugins? | MDX Loader Pipeline |
| How do the Webpack, Next.js, Vite, and Rolldown loader plugins intercept and transform documentation source files? | Bundler Plugins |
| How do plugins generate type-safe schema validation, last-modified git timestamps, and virtual index files for documentation? | Content Compiler Plugins |
| How are MDX strings compiled and evaluated dynamically on the server and in the browser for remote content? | MDX Runtime Compilation |
| What foundational primitive components does fumadocs-ui/base-ui provide for dialogs, navigation, cards, and forms? | Base UI Components |
| How does fumadocs-ui/radix-ui implement accessible primitives like popovers, collapsibles, scroll areas, and search dialogs? | Radix UI Primitives |
| How do sidebar slots, headers, containers, footers, and page actions compose documentation layouts across frameworks? | Shared Layout Architecture |
| How does the Flux layout arrange the modern dual-sidebar, responsive navbar, and article structure? | Ui Layouts Layout |
| How are table of contents trees extracted, highlighted dynamically on scroll, and displayed in sidebars or inline components? | Table of Contents |
| How do interactive client and server code blocks handle syntax styling, copy actions, dynamic tab groups, and file trees? | Code Block Components |
| How do CSS presets, Tailwind typography plugins, and theme variations (such as Catppuccin, Shadcn, and Vitepress) apply styling? | Theme Styles and CSS |
| How does the shared fumadocs-api-docs package handle schema dereferencing, mock sampling, and reusable UI widgets? | API Docs Primitives |
| How are OpenAPI v3 and Swagger specifications parsed, validated, and converted into static MDX documentation pages? | OpenAPI Document Generation |
| How does the OpenAPI renderer render interactive API endpoint cards, request parameters, response schemas, and curl try-it-out widgets? | OpenAPI Interactive UI |
| How does Fumadocs automatically generate code snippets for cURL, JavaScript, Python, Go, and C# from OpenAPI endpoint schemas? | Code Sample Generators |
| How are AsyncAPI specifications loaded, dereferenced, and converted into asynchronous messaging documentation? | AsyncAPI Document Processing |
| How does Fumadocs render protocol-specific message configurations for Kafka, MQTT, WebSockets, AMQP, and SQS? | AsyncAPI Protocol Bindings |
| How does Fumadocs read Obsidian vaults and convert wikilinks, callouts, block IDs, and comments to standard MDX? | Obsidian Vault Integration |
| How does fumadocs-local-md parse pure markdown and execute embedded expressions with Node and browser clients? | Local Markdown Runtime |
| How does Fumadocs integrate with Content Collections for static type-safe document fetching and metadata mapping? | Content Collections Adapter |
| How does the fumapy Python module inspect docstrings and generate structured documentation data for Fumadocs? | Python Docstring Extractor |
| How does Fumadocs ingest structured portable text and document trees from Sanity headless CMS into docs pages? | Sanity CMS Integration |
| How does Fumadocs fetch and render documentation collections stored within BaseHub headless CMS? | BaseHub Integration |
| How does Fumadocs provide manual and automated installations of documentation components compatible with shadcn/ui? | shadcn/ui Docs Registry |
| How do the CLI commands customize components, add registry snippets, export EPUB documents, and inspect file trees? | Fumadocs CLI |
| How does create-fumadocs-app scaffold projects across frameworks (Next.js, React Router, TanStack Start) and linters? | Create App Generator |
| How does the built-in Waku-based preview server provide live hot reloading, AI chat search, and dynamic OG image generation? | Preview Server |
| How does Fumadocs extract TypeScript AST interfaces, type aliases, and JSDoc tags to build interactive type tables? | TypeScript Type Table Extraction |
| How does fumadocs-twoslash integrate with Shiki to display compiler diagnostics, type hints, and hover popups? | Twoslash Type Hover |
| How does the fumadocs-story package parse component props and render live interactive playground controls inside documentation? | Interactive Component Playground |
| How does STF parse, format, and render structured documentation payloads across server and client boundaries? | Structured Text Format |
| How does fumadocs-epub bundle documentation pages, assets, stylesheets, and tables of contents into EPUB ebooks? | EPUB Book Export |
| How do fumadocs-vite and vite-data provide HMR and data resolution for non-Next.js build tools? | Vite Integration Plugins |
Related
On This Page
OverviewArchitecture and Design PhilosophyMonorepo Package Structure and RolesCore Runtime and Content CompilersUI Implementations and LayoutsTooling, Extensibility, and Preview PackagesContent Compilation and Source ProcessingDocument Schemas and Collection ConfigurationRuntime and Dynamic MDX CompilationPresentation Primitives and Layout SystemsHeadless UI Implementations and UI RegistriesLayout Presets and Markdown Compilation PipelineTooling and Extensibility EcosystemSpecification Generators and Language Integration PluginsStandalone Content Sources and Export UtilitiesDeveloper CLI WorkflowsWhere to go nextRelated