Overview
The Search API provides server and client-side search capabilities for Fumadocs. It supports multiple search backends including Orama, Algolia, and custom implementations.Server API
createSearchAPI()
Create a search API endpoint with Orama.Search implementation type:
'simple': Basic full-text search'advanced': Search with structured content and headings
Configuration options for the search implementation
Object containing:
search(query, options?): Search functionexport(): Export search indexesGET: Route handler for search requestsstaticGET: Route handler for exporting indexes
SimpleOptions
Options for simple search.Array of search indexes or function that returns indexes
Language for search (affects tokenization and stemming)
Custom search parameters passed to Orama
AdvancedOptions
Options for advanced search with structured content.Array of advanced search indexes with structured data
Index
Simple search index structure.Page title
Searchable content
Page URL
Page description
Navigation breadcrumbs
Additional keywords for search
AdvancedIndex
Advanced search index with structured content.Unique identifier for the page
Page title
Preprocessed MDX content with headings and sections
Page URL
Tags for filtering search results
createFromSource()
Create a search API directly from a loader source.Output from the loader function
Custom function to build search index from page data
Map language codes to Orama language settings
Search API instance with route handlers
createI18nSearchAPI()
Create a search API with internationalization support.Search implementation type
Internationalization configuration
Indexes with locale property
Map locale codes to Orama languages
Client API
useDocsSearch()
React hook for search functionality.Search client configuration (see Client types)
Debounce delay for search requests (in milliseconds)
Perform search even when query is empty
Dependency array for re-querying (like useEffect)
Object containing:
search: Current search query stringsetSearch: Function to update search queryquery.isLoading: Whether search is in progressquery.data: Search results or ‘empty’query.error: Error if search failed
Client Types
Supported search client configurations.type='fetch'
Fetch search results from an API endpoint
api: API endpoint URL
type='static'
Use a static exported database for client-side search
db: Exported Orama database
type='algolia'
Use Algolia for search
appId: Algolia application IDapiKey: Algolia search API keyindexName: Index name
type='orama-cloud'
Use Orama Cloud for search
endpoint: Orama Cloud endpointapiKey: Orama Cloud API key
SortedResult
Search result structure.Unique result identifier
Result URL (may include hash for headings)
Result type
Result content with search term highlights (using
<mark> tags)Navigation breadcrumbs for the result
createContentHighlighter()
Create a highlighter for search results.Search query or regex pattern
Object with methods:
highlight(content): Returns array of text segments with highlight flagshighlightMarkdown(content): Returns markdown with<mark>tags