Nextra includes a full-page search feature powered by Pagefind — a static search library that indexes your HTML output at build time and serves results entirely client-side with no server or external API required. Search is enabled by default; you only need to install Pagefind and add aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shuding/nextra/llms.txt
Use this file to discover all available pages before exploring further.
postbuild script to activate it.
Setup
Pagefind indexes
.html files, so the indexing must run after your Next.js build completes. Add a postbuild script to package.json:Add the generated
_pagefind/ directory to your .gitignore so index files are not committed to version control:Run your build and check that a
_pagefind/ directory exists in public/ (server builds) or out/ (static exports). Start your app and use the search bar to confirm results appear correctly.How It Works
When search is enabled, Nextra adds adata-pagefind-body attribute to the <main> element of each page. Pagefind uses this attribute to identify the content regions to index, so only the page body is searchable — not navigation, headers, or footers.
Configuration
Search is enabled by default. Configure it innext.config.mjs by passing a search option to nextra():
Disable Search
Exclude Code Blocks from Index
By default, code blocks are included in the search index. To keep search enabled but exclude code block content, setcodeblocks: false:
codeblocks: false is set, Nextra adds data-pagefind-ignore="all" to every <pre> element so Pagefind skips them during indexing.
The default value of
search is { codeblocks: false }, meaning code
blocks are excluded from the index unless you explicitly set
search: true or search: { codeblocks: true }.Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
search | boolean | { codeblocks: boolean } | { codeblocks: false } | Enable/disable search or configure code indexing. |
search.codeblocks | boolean | false | Whether to include code blocks in the search index. |
Alternative Search Providers
Pagefind works great for most documentation sites, but Nextra also supports replacing the default search with other providers.Typesense
Self-hostable, typo-tolerant search engine with a community-maintained
adapter. Ideal for large documentation sites that need faceted search.
AI Search (Inkeep)
Add an AI-powered chat assistant to your docs using Inkeep, letting users
ask natural language questions instead of typing keywords.