Introduction
This section provides an overview of DocuBook.
Why DocuBook Exists
For years, I worked on documentation projects where the biggest effort was not writing content, but getting the theme and styling right. Most of the time was eaten by configuring CMS plugins and tweaking layouts instead of focusing on the actual documentation.
That frustration inspired me to build a docs framework from the ground up in the React ecosystemβone that keeps the writing experience front and center. DocuBook is designed to let you focus on content while giving you a flexible, developer-friendly foundation thatβs also open source.
Open Source Philosophy
DocuBook is proudly open-source! π We believe in creating an accessible, collaborative platform that thrives on community contributions.
Contribute
Interested in helping us improve? Check out our GitHub repository to get started! From feature suggestions to bug fixes, all contributions are welcome.
Project Overview
DocuBook is more than just a documentation template. It's a complete ecosystem designed for modern React development. Key features include:
- Markdown & MDX Support: Easily write documentation in Markdown, with the option to include interactive components via MDX.
- Customizable Themes: Designed with a minimalist ShadCN-inspired theme that's easy to style.
- SEO-Optimized: Each page is SEO-ready, ensuring search engines can find and rank your content.
- Interactive Code Blocks: Beautifully styled, language-specific code blocks for an enhanced reading experience.
- Prebuilt Navigation Tree: Intelligent caching system that prebuilds navigation structure for optimal performance.
- CLI Tools: Command-line utilities for scaffolding and managing documentation projects.
- Multi-Framework Support: Templates for different React frameworks and deployment strategies.
Key Features
| Feature | Description |
|---|---|
| MDX Support | Write interactive documentation with MDX. |
| Nested Pages | Organize content in a nested, hierarchical structure. |
| Pagination | Split content across multiple pages. |
| Syntax Highlighting | Highlight code for better readability. |
| Code Line Highlighting & Titles | Highlight specific lines with descriptive titles. |
| Interactive Code Blocks | Language-specific and interactive code display. |
| Custom Markdown Components | Embed custom, reusable components in your docs. |
| Static Site Generation | Generate a static, high-performance site. |
| SEO-Optimized | Structured for optimal search engine indexing. |
| Prebuilt Navigation | Prebuild navigation tree with intelligent caching |
| CLI Tools | Command-line utilities for project management |
| Multi-Template Support | Templates for different frameworks and deployments |
| MDX Cache Compilation | Efficient reuse of parsed MDX across metadata and page rendering to avoid duplicated compilation |
Technology & Libraries
DocuBook leverages cutting-edge technologies to ensure performance and flexibility:
UI & Styling
- Tailwind CSS 4 - Utility-first styling for quick, clean designs
- Shadcn-UI - Elegant, accessible components for a polished look
- Radix UI - Unstyled, accessible UI primitives
Content & Search
- next-mdx-remote - Enables MDX support for dynamic, interactive Markdown content
- Algolia DocSearch - Powerful search functionality with instant results
- @docubook/docs-tree - CLI tool for prebuilding navigation structures
- Purpose: Prebuild navigation tree for optimal performance
- Features: Intelligent caching, multi-package manager support
- Benefits: Faster builds, reduced runtime computation
- Usage: Automatic prebuild in production deployments
Development Tools
- TypeScript - Type-safe development experience
- ESLint - Code linting and formatting
- Turbo - High-performance build system for monorepos
Available Templates
DocuBook provides multiple deployment-ready templates for different use cases:
π Next.js Templates
Next.js + Vercel (nextjs-vercel)
- Best for: Server-side rendering, static site generation
- Deployment: Optimized for Vercel platform
- Features: Edge functions, ISR, API routes
- Use case: Production apps requiring SEO and performance
Next.js + Docker (nextjs-docker)
- Best for: Containerized deployments
- Deployment: Standalone Docker images
- Features: Self-contained, cloud-agnostic
- Use case: Enterprise deployments, custom infrastructure
β‘ React Router Template
React Router + Vite (react-router) - coming soon
- Best for: Client-side applications, SPAs
- Deployment: Static hosting (Netlify, GitHub Pages, etc.)
- Features: Fast development, modern React patterns
- Use case: Developer portals, lightweight documentation
All templates include:
- β Pre-configured build scripts
- β Development and production optimizations
- β SEO-ready configuration
- β Modern React patterns and best practices
MDX Processing Comparison (Before vs After Optimization)
To make the docs runtime more efficient, DocuBook now separates metadata reading from full MDX compilation and deduplicates repeated calls in the same request.
Why this matters
Docs pages are one of the most frequently visited routes in most projects. Reducing repeated MDX work improves server response time and lowers CPU usage, especially when traffic increases.
In the old flow, a single page request repeated work multiple times:
request page
β
generateMetadata()
β
getDocsForSlug()
β
read mdx file
β
parse frontmatter
β
compile MDX
DocsPage()
β
getDocsForSlug() (called again)
β
compile MDX again
getDocsTocs()
β
read mdx file again
β
parse headings
The current flow avoids unnecessary compilation and duplicate reads:
request page
β
generateMetadata()
β
getDocsFrontmatterForSlug()
β
getDocsRawForSlugCached()
β
read mdx file + parse frontmatter + extract TOC
DocsPage()
β
getDocsForSlug()
β
computeDocsForSlugCached()
β
reuse getDocsRawForSlugCached() data
β
compile MDX once
getDocsTocs()
β
reuse getDocsRawForSlugCached() result
β
no extra file read
Quick Metrics (Per Request)
| Metric | Before | After |
|---|---|---|
| MDX file reads | 3x | 1x |
| Frontmatter parsing | 2x | 1x |
| MDX compilation | 2x | 1x |
| TOC extraction | 1x (separate read path) | 1x (from shared raw cache) |
Note: The current optimization uses two cache layers! so metadata, page content, and TOC all share the same raw MDX processing in one request.
Practical Impact
- Less CPU work for metadata generation (no unnecessary MDX compile).
- No repeated file-system reads during a single docs page render.
- Better performance consistency for docs routes under load.
- Cleaner separation of concerns between metadata and full content rendering.
DocuBook transforms documentation from a simple template into a professional development platform that scales with your project's needs. π―
Published on Nov 29, 2024