Prerequisites
- Docusaurus v3.9.2 or higher
- Node.js 20.0 or higher
- React 18.0+ or React 19.0+
Installation
Install the@docsearch/docusaurus-adapter package:
Don’t have your Algolia credentials yet? Apply to DocSearch to get started for free.
Configuration
Add to Docusaurus config
Configure DocSearch in your
docusaurus.config.js file using the themeConfig.docsearch option:docusaurus.config.js
The
themeConfig.algolia configuration is still supported as a backward-compatible alias, but themeConfig.docsearch is the recommended approach.Complete Configuration Example
Here’s a comprehensive example with common options:docusaurus.config.js
Configuration Options
Required Options
Your Algolia application ID.
Your Algolia Search API key (public, search-only key).
The name of your Algolia index to search.
Search Behavior Options
Enables contextual search, which filters results based on the current documentation version and language. Defaults to
false.When enabled, DocSearch automatically adds facet filters based on:- Current documentation version
- Current language
- Current documentation plugin ID
Additional Algolia search parameters to apply to all queries.
Path to the search page. Set to
false to disable the search page. Defaults to 'search'.When enabled, adds a “See all results” link at the bottom of the search modal.Regular expression to identify external URLs. Results matching this pattern will open in a new window instead of using client-side routing.
Replace parts of the search result URLs before navigation.
UI Customization Options
Placeholder text for the search input. Defaults to
'Search docs'.Localized strings for the search interface. Docusaurus automatically provides translations for supported locales.
Ask AI Options
Configuration for the Ask AI feature.
The Algolia Assistant ID for Ask AI functionality.
Enable the side panel UI for Ask AI. When
true, Ask AI opens in a side panel instead of replacing the search modal. Defaults to false.Show suggested questions in the Ask AI interface. Defaults to
false.API key for Ask AI. If not provided, uses the main
apiKey.App ID for Ask AI. If not provided, uses the main
appId.Index name for Ask AI. If not provided, uses the main
indexName.Contextual Search
Contextual search automatically filters results based on the current page context. This is especially useful for versioned or multi-language documentation.docusaurus.config.js
- Version:
version:2.0(based on the current doc version) - Language:
language:en(based on the current locale) - DocPlugin:
docusaurus_tag:docs-default-current(based on the plugin ID)
Multi-Index Search
You can search across multiple Algolia indices:docusaurus.config.js
Ask AI Side Panel
The side panel provides a persistent AI assistant alongside your documentation:docusaurus.config.js
sidePanel: true, users can:
- Open the side panel with a dedicated button in the navbar
- Keep the panel open while browsing documentation
- Switch between search and Ask AI seamlessly
Custom Styling
DocSearch inherits Docusaurus theme colors automatically. You can further customize with CSS:src/css/custom.css
Programmatic Access
You can access DocSearch programmatically in Docusaurus using client modules:src/clientModules/searchControl.js
docusaurus.config.js:
docusaurus.config.js
Migration from Algolia Plugin
If you’re migrating from@docusaurus/theme-search-algolia:
The
themeConfig.algolia configuration continues to work as a backward-compatible alias, so you can migrate at your own pace.Troubleshooting
Search not appearing
Ensure you have added the search component to your navbar:docusaurus.config.js
No results found
Verify your index exists and contains data:- Check your Algolia dashboard
- Ensure your
indexNamematches exactly - Verify
apiKeyhas search permissions - Check that contextual filters aren’t too restrictive
Styling conflicts
If DocSearch styles conflict with your theme:src/css/custom.css
Next Steps
Configuration
Learn about all available configuration options
Styling
Customize the appearance of your search
Ask AI
Enable AI-powered search assistance
Crawler Configuration
Configure the DocSearch crawler for your site
