Search
LitMDX includes full-text search powered by Pagefind — a static search library that runs entirely in the browser. No server, no external API, no API key.
How it works
litmdx buildreads all.mdxsource files, extracts text and titles, and generates a search index atdist/pagefind/.- At runtime, the search modal dynamically loads
pagefind.jsfrom/pagefind/pagefind.jsand queries the index in the browser.
Note
Search is not available in dev mode. The Pagefind index only exists after running litmdx build. In dev, the search modal opens but returns no results — this is expected.
Opening the search modal
Users can open the search modal in two ways:
- Click the Search button in the header.
- Press
⌘Kon macOS orCtrl+Kon Windows/Linux.
Press Esc to close.
Keyboard navigation
Once results appear, use the keyboard to navigate:
| Key | Action |
|---|---|
↓ / ↑ | Move between results |
Enter | Navigate to the selected result |
Esc | Close the modal |
Search index content
The search index is built from the raw MDX source files. LitMDX extracts:
- Page title (from frontmatter
titleor the first# Heading) - Body text (Markdown prose, stripped of syntax and JSX components)
- URL (derived from the file path using the same routing logic)
Code blocks, import statements, and JSX component markup are excluded from the index.
Result highlighting
Matched terms in result excerpts are wrapped in <mark> tags and styled with a highlight color.
Installation requirement
Pagefind must be installed in your project:
bun add -D pagefindIf pagefind is not installed, the build still succeeds but a warning is printed and the search index is skipped.

