MDX is a format that lets you write JSX directly in your Markdown documents. It combines the simplicity of Markdown with the power of React components, allowing you to embed interactive elements, styled layouts, and dynamic content within your documentation pages.
Features
This page is a live demonstration of every feature available in ClearDocs. Each section below shows a real, working example of a component or capability — the same ones you will use when building your own documentation. Use this page as both a reference guide and a visual catalog of what ClearDocs can do.
Every page in ClearDocs includes a Copy page dropdown button next to the title, allowing readers to export content as Markdown or plain text with a single click.
Code Blocks
ClearDocs renders code blocks with syntax highlighting for 65+ programming languages. Every code block includes line numbers, a language badge, and a copy-to-clipboard button — all enabled by default with no configuration.
JavaScript
async function fetchDocumentation(slug) {
const response = await fetch(`/api/docs/${slug}`)
const data = await response.json()
return data.content
}TypeScript
interface DocumentPage {
title: string
slug: string
content: string
lastUpdated: Date
}
function formatPage(page: DocumentPage): string {
return `# ${page.title}\n\n${page.content}`
}Python
from pathlib import Path
def build_navigation(docs_dir: str) -> list[dict]:
pages = []
for mdx_file in Path(docs_dir).rglob("*.mdx"):
pages.append({
"name": mdx_file.stem.replace("-", " ").title(),
"path": str(mdx_file.relative_to(docs_dir)),
})
return sorted(pages, key=lambda p: p["path"])Bash
npm install
npm run dev
npm run build
npm run format:checkJSON
{
"name": "cleardocs",
"version": "1.0.0",
"scripts": {
"dev": "next dev --turbopack",
"build": "next build --turbopack"
}
}Line Highlighting
Draw attention to specific lines of code using the {1,3-5} syntax after the
language identifier. Highlighted lines receive a distinct background color,
making it easy to point readers to the most important parts of a code example.
interface User {
id: string
name: string
email: string
role: 'admin' | 'user'
}Line Numbers
Line numbers are enabled by default on all code blocks. Add showLineNumbers
explicitly or showLineNumbers=N to start numbering from a specific line —
useful when showing a snippet from the middle of a larger file.
import { cache } from 'react'
import { readFile } from 'fs/promises'
const getCachedContent = cache(async (slug: string) => {
const filePath = `./content/${slug}.mdx`
return readFile(filePath, 'utf-8')
})
export default async function DocPage({ params }) {
const content = await getCachedContent(params.slug)
return <MDXRemote source={content} />
}File Title
Show a file path header above any code block with title="filename". This
tells readers exactly which file the code belongs to — essential for tutorials
and guides where code spans multiple files.
import { SignJWT, jwtVerify } from 'jose'
const secret = new TextEncoder().encode(process.env.JWT_SECRET)
export async function createSession(payload: Record<string, unknown>) {
return new SignJWT(payload)
.setProtectedHeader({ alg: 'HS256' })
.setExpirationTime('7d')
.sign(secret)
}Diff Highlighting
Show code changes inline with // [!code ++] and // [!code --] markers.
Added lines appear with a green background and removed lines with a red
background. The markers themselves are stripped from the rendered output, keeping
the code clean and readable.
function getConfig() {
return {
theme: 'light',
theme: 'dark',
debug: true,
debug: false,
}
}Code Groups
The Code Group component organizes multiple code blocks into a tabbed interface. This is ideal for showing the same command across different package managers, or the same logic implemented in different languages. Readers pick their preferred tab and the selection persists.
npm install next react react-domyarn add next react react-dompnpm add next react react-domWord Highlighting
Highlight every occurrence of a specific word or pattern using the /pattern/
syntax. This is useful for calling out variable names, function calls, or
important identifiers within a code example.
interface DocumentPage {
title: string
slug: string
}
function renderPage(page: DocumentPage): string {
return `# ${page.title}`
}Collapsible Code
Long code blocks can overwhelm a page. The expandable metastring collapses
the block to a configurable number of visible lines with an expand button.
Readers see the beginning of the code and can expand to view the rest when they
need it.
GitHub-Style Alerts
Alerts are callout blocks that draw reader attention to important information. ClearDocs supports all six GitHub alert types, each with a distinct color and icon to convey the right level of urgency.
ℹ️ NOTE Notes highlight information that users should take into account, even when skimming.
💡 TIP Tips provide optional information to help users be more successful.
📝 IMPORTANT Important information that users need to know to achieve their goal.
⚠️ WARNING Urgent information that needs immediate attention to avoid problems.
⚡ CAUTION Advises about risks or negative outcomes of certain actions.
Tabs
The Tabs component organizes content into tabbed panels. Use it to present
alternative approaches, framework-specific instructions, or any content where
readers need to choose between options. Tab selections can be synced across
pages using the syncKey prop, so a reader who picks "React" on one page sees
"React" selected on every other page.
React uses a virtual DOM and JSX syntax for building user interfaces with a component-based architecture.
Steps
The Steps component turns an ordered list into a visual step-by-step guide with numbered circles and vertical connectors. This is the standard format for tutorials, onboarding flows, and installation instructions — it makes sequential tasks easy to follow and visually distinct from regular content.
-
Clone the repository
Run
git cloneto get the project files on your local machine. -
Install dependencies
Run
npm installto install all required packages. -
Configure environment
Run
bash scripts/setup-env.shor copy.env.exampleto.env.local. -
Start development server
Run
npm run devto start the development server with hot reload.
Cards
Cards provide a grid-based layout for feature showcases, quick navigation, and content overviews. Each card can include a title, description, optional icon, and optional link. The grid is responsive — it stacks on mobile and expands to your chosen column count on larger screens.
Fast Builds
Turbopack-powered builds with sub-second hot reload for instant feedback during development.
MDX Support
Write documentation in Markdown with the full power of React components embedded directly in your pages.
Full-Text Search
Built-in search across all pages with scored ranking, context snippets, and Cmd+K keyboard shortcut.
Accordion
The Accordion component creates collapsible content sections — ideal for FAQs, troubleshooting guides, and any content where readers benefit from progressive disclosure. Accordions support smooth animation, URL hash deep-linking (so you can link directly to a specific open accordion), and independent open/close state.
ClearDocs uses JWT-based session cookies for authentication in private mode. Visitors enter a shared password, which is verified against a server-side SHA-256 hash using timing-safe comparison. On success, a JWT session cookie is set with a 14-day expiry. Sessions include browser fingerprinting and are invalidated if the fingerprint changes.
Yes. ClearDocs ships with 26 color themes, each generating coordinated light
and dark mode palettes automatically. Set the THEME_VARIANT environment
variable to any of the 26 options and restart the dev server — the entire
site updates instantly with no code changes.
Badge
Badges are inline status indicators for labeling features, versions, and lifecycle stages. Five color variants communicate different states at a glance.
Default Info New Beta DeprecatedParameter Fields
The ParamField component provides structured documentation for API parameters. Each field displays the parameter name, data type, location (path, query, body, header), required/optional status, and default value in a consistent, scannable format.
slugstringpathrequiredThe unique identifier for the document page. Used in the URL path to resolve the correct content file.
pageintegerqueryDefault: 1Page number for paginated results. Must be a positive integer. The API returns 20 items per page by default.
statusstringqueryFilter by document status. Allowed values: draft, published, archived.
When omitted, all statuses are returned.
Response Fields
The ResponseField component documents the shape of API response bodies. Each field shows the name, data type, and whether the field is always present (required) or conditionally included. Nested objects are documented using dot notation.
idstringrequiredUnique identifier for the document, generated on creation.
titlestringrequiredThe document title as provided during creation. Used in navigation and search results.
createdAtstring (ISO 8601)Timestamp of when the document was created, in ISO 8601 format.
File Tree
The FileTree component renders a visual directory structure from indented text. Use it to show project layouts, folder hierarchies, and file organization without screenshots that go stale.
Changelog
The Changelog component provides a timeline-based layout for tracking technical changes across releases. Each entry supports seven label types (added, fixed, changed, removed, breaking, deprecated, security) with color-coded badges. This format is designed for developer audiences who need a complete, detailed record of every change.
Added Dark mode toggle with light/dark/system modes and prefers-color-scheme auto-detection.
Added Copy page as Markdown/Plain Text dropdown button next to page titles.
Added 65+ programming languages for syntax highlighting (expanded from 26) with 45 aliases.
Added Auto-generated sitemap.xml, llms.txt, llms-full.txt, OpenGraph meta tags, canonical URLs, and JSON-LD structured data.
Added Health check endpoint at /api/health.
Changed Replaced hardcoded green colors with semantic theme aliases for full 26-palette support.
Changed Reduced session duration from 30 days to 14 days.
Changed Standardized spacing across all components for tighter, commercial-grade layout.
Fixed Focus-visible indicators on interactive elements for WCAG 2.4.7 compliance.
Added Line highlighting, line numbers, file titles, diff highlighting, and code groups for code blocks.
Added Tabs, Steps, Cards, Accordion, Badge, ParamField, and ResponseField components.
Changed ApiBlock now supports multiple response tabs, authentication indicators, deprecation marking, rate limiting info, and auto-generated cURL examples.
Added Initial release with MDX support, syntax highlighting, Mermaid diagrams, GitHub alerts, and global search.
Release Notes
Release Notes are designed for end-user audiences. While the Changelog above provides a complete technical record of every change, Release Notes highlight only the changes that matter to your users — written in benefit-focused language with a card-based layout that communicates the value of each update.
Commercialization Readiness and AI Features
New Dark mode toggle with light, dark, and system modes that auto-detects your device preference.
New Copy page as Markdown or plain text with a dropdown button next to every page title, for pasting into AI tools like ChatGPT, Claude, or Cursor.
New 65+ programming languages for syntax highlighting, up from 26, covering Swift, Kotlin, Dart, Scala, Elixir, Haskell, Rust, Zig, and many more.
New Auto-generated llms.txt and llms-full.txt endpoints for AI agent discoverability.
Improved 26 theme variants now render correctly across all UI components with semantic color aliases.
Improved SEO with dynamic sitemap, OpenGraph meta tags, canonical URLs, and JSON-LD structured data on every page.
Security Session duration reduced from 30 days to 14 days. Focus-visible indicators added for WCAG accessibility compliance.
Public Access Mode and Release Notes
New Public/private access mode toggle via ACCESS_MODE environment variable. Set to public for open documentation or private for password-protected access.
New Release Notes component for user-facing announcements with card-based layout and 8 highlight types.
Improved Dynamic robots.txt that automatically allows search engine indexing in public mode and blocks all crawlers in private mode.
Rich Code Blocks and Documentation Components
New Line highlighting, diff markers, word highlighting, collapsible code, and tabbed code groups for code blocks.
New Tabs, Steps, Cards, Accordion, Badge, and structured API field documentation components.
Fix Code blocks render without hydration flashes on page refresh.
Mermaid Diagrams
Mermaid diagrams are written in standard Markdown code fences and rendered as interactive SVG graphics directly on the page. ClearDocs supports 15+ diagram types — from flowcharts and sequence diagrams to gantt charts and mindmaps. All diagram output is sanitized through DOMPurify for security.
Tables
Standard Markdown tables render with responsive horizontal scrolling on narrow viewports, alternating row backgrounds for readability, and header alignment support.
| Feature | Status | Description |
|---|---|---|
| MDX Support | Available | Full MDX v3 support |
| Code Highlighting | Available | 65+ languages |
| Mermaid Diagrams | Available | 15+ diagram types |
| Global Search | Available | Full-text with Cmd+K |
| Dark Mode | Available | Light/Dark/System |
| Theme Variants | Available | 26 color palettes |
| Authentication | Available | JWT-based sessions |
| Auto Navigation | Available | File-system based |
| AI Readiness | Available | llms.txt + copy page |
| SEO | Available | Sitemap + OG + JSON-LD |
Comparison Table
The Comparison Table component lets you create side-by-side feature comparisons
using 10 visual indicator types. Use it to compare your product against
competitors, compare pricing tiers, or compare technology options. The
highlight prop visually emphasizes your recommended column.
Documentation Platform Comparison
| Feature | ClearDocs | Docusaurus | GitBook | Mintlify |
|---|---|---|---|---|
| Self-Hosted | Included | Included | Not available | Not available |
| Open Source (MIT) | Included | Included | Not available | Not available |
| Password-Protected Mode | Included | Not available | Premium | Premium |
| MDX Components | Included | Included | Not available | Included |
| Full-Text Search | Included | Partial | Included | Included |
| Dark Mode | Included | Included | Included | Included |
| 26 Theme Variants | Included | Not available | Not available | Not available |
| Mermaid Diagrams | Included | Partial | Included | Included |
| API Documentation Blocks | Included | Not available | Included | Included |
| Syntax Highlighting | Included | Included | Included | Included |
| Auto Sidebar from Filesystem | Included | Included | Not available | Included |
| AI Agent Endpoints (llms.txt) | Included | Not available | Not available | Not available |
| GitHub-Style Alerts | Included | Partial | Not available | Included |
| Code Groups | Included | Included | Not available | Included |
| Comparison Tables | Included | Not available | Not available | Not available |
| Zero Config Setup | Included | Not available | Included | Included |
| No Vendor Lock-In | Included | Included | Not available | Not available |
| Pricing | One-time, unlimited seats | Free (OSS) | Per-seat/month | Per-seat/month |
The 10 indicator types available for comparison table cells are:
check— included (green checkmark)cross— not available (red X)partial— limited support (amber minus)info— informational note (blue info)star— premium/paid feature (purple star)clock— coming soon (gray clock)plus— available as add-on (teal plus)lock— enterprise/restricted (gray lock)sparkle— new/beta feature (violet sparkles)zap— upgrade tier (amber zap)- Any other string renders as plain text.
Use the highlight prop (column index) to visually emphasize a recommended
option with a brand-tinted column and "Recommended" label.
Inline Code
Use backticks for inline code like npm run dev or next.config.mjs. Variable
names like searchIndex and file paths like app/globals.css are also rendered
with inline code styling.
Links
- Internal links: Introduction
- External links: Next.js Documentation
Text Formatting
Standard Markdown formatting is fully supported:
- Bold text for emphasis
- Italic text for subtle emphasis
Strikethroughfor deprecated content- Bold and italic combined
Lists
Ordered List
- Clone the repository
- Install dependencies
- Run the setup script
- Start the development server
Unordered List
- Supports nested lists
- Second level
- Third level
- Second level
- Back to first level
Task List
- Set up Next.js with MDX
- Add syntax highlighting (65+ languages)
- Implement global search with Cmd+K
- Add Mermaid diagram support (15+ types)
- Add API documentation blocks with multi-response tabs
- Line highlighting, diff markers, and word highlighting
- Code groups and tabbed code blocks
- Tabs, Steps, Cards, Accordion, Badge
- ParamField and ResponseField components
- Table of Contents with scroll-spy
- Dark mode toggle with system auto-detection
- 26 theme variants via environment variable
- Copy page as Markdown/Plain Text button
- Sitemap, OpenGraph, JSON-LD, canonical URLs
- llms.txt and llms-full.txt for AI agents
- Image zoom lightbox
- Embed component with URL allowlist
- Changelog and Release Notes components
- Health check endpoint
- Add versioning support
- Add i18n support
API Documentation Blocks
The ApiBlock component renders interactive REST API endpoint documentation with color-coded method badges, request/response JSON with syntax highlighting, authentication indicators, and auto-generated cURL examples. It is the centerpiece component for API reference documentation.
/api/v1/statusNo auth requiredCheck the service health status. Returns the current uptime percentage and software version.
/api/v1/tokensBearer TokenGenerate an access token with a specified scope and expiration. The token is returned immediately and cannot be retrieved again after this response.
Blockquotes
Documentation is a love letter that you write to your future self.
— Damian Conway