Skip to main content
DocSearch provides a native Docusaurus theme that replaces the default search functionality with Algolia-powered search. The adapter is specifically designed for Docusaurus v3 and integrates seamlessly with the Docusaurus ecosystem.

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

1

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.
2

Configure the theme (optional)

If you want to customize the search experience, add the theme to your docusaurus.config.js:
docusaurus.config.js

Complete Configuration Example

Here’s a comprehensive example with common options:
docusaurus.config.js

Configuration Options

Required Options

string
required
Your Algolia application ID.
string
required
Your Algolia Search API key (public, search-only key).
string
required
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
object
Additional Algolia search parameters to apply to all queries.
boolean | string
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.
string
Regular expression to identify external URLs. Results matching this pattern will open in a new window instead of using client-side routing.
object
Replace parts of the search result URLs before navigation.

UI Customization Options

string
Placeholder text for the search input. Defaults to 'Search docs'.
object
Localized strings for the search interface. Docusaurus automatically provides translations for supported locales.

Ask AI Options

object
Configuration for the Ask AI feature.
string
required
The Algolia Assistant ID for Ask AI functionality.
boolean
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.
boolean
Show suggested questions in the Ask AI interface. Defaults to false.
string
API key for Ask AI. If not provided, uses the main apiKey.
string
App ID for Ask AI. If not provided, uses the main appId.
string
Index name for Ask AI. If not provided, uses the main indexName.
Contextual search automatically filters results based on the current page context. This is especially useful for versioned or multi-language documentation.
docusaurus.config.js
With contextual search enabled, DocSearch automatically adds facet filters:
  • 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)
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
When 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
Register the client module in docusaurus.config.js:
docusaurus.config.js

Migration from Algolia Plugin

If you’re migrating from @docusaurus/theme-search-algolia:
1

Install the new package

2

Update configuration

Change themeConfig.algolia to themeConfig.docsearch:
docusaurus.config.js
3

Update deprecated options

Replace searchPagePath boolean with string or false:
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:
  1. Check your Algolia dashboard
  2. Ensure your indexName matches exactly
  3. Verify apiKey has search permissions
  4. 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