FairGarden Docs

FairGarden Docs

Build-time optimized documentation infrastructure for React and Next.js sites. This package was originally developed to power Base UI's documentation with syntax-highlighted code demos, auto-extracted TypeScript API references, and client-side search.

Key Features

  • Code Demos with syntax highlighting, multiple variants (CSS Modules, Tailwind), and live previews
  • Type Documentation automatically extracted from TypeScript at build time
  • Search with Orama-powered client-side indexing
  • Zero runtime overhead - heavy processing happens during build via webpack loaders

Core Concepts

New to the codebase? Start with the Architecture page to understand how the build-time optimization, factory pattern, and data flows work together.

Installation

pnpm install @fairgarden/docs

Then configure your Next.js app with withFairGardenDocs:

import { withFairGardenDocs } from '@fairgarden/docs/withFairGardenDocs';

export default withFairGardenDocs()(nextConfig);

Documentation

  • Architecture - System design, data flows, and key decisions
  • Components - CodeHighlighter, CodeProvider, context providers
  • Hooks - useCode, useDemo, useTypes, useSearch
  • Commands - CLI tools for validation
  • Factories - createDemo, createTypesMeta, factory patterns
  • Pipeline - Loaders, transformers, enhancers, and build-time tools
  • Patterns - Architectural patterns and best practices
  • Conventions - Filesystem and coding conventions

Contributing

See the Contributing guide.

License & Use

This project is licensed under the MIT License.