Migrate the Docusaurus adapter from v4
DocSearch v5 requires themeConfig.docsearch, a nonempty indices array, and Agent Studio for Ask AI. Update the adapter and configuration together.
Review the broader DocSearch v4 migration guide for changes outside the Docusaurus adapter.
1. Check compatibility
Upgrade the site to Node.js 20 or later and Docusaurus 3.10.2 or later in the Docusaurus 3 release line. Use React and React DOM 18 or 19.
2. Install the v5 adapter
Install @docsearch/docusaurus-adapter@^5:
- npm
- Yarn
- pnpm
- Bun
npm install @docsearch/docusaurus-adapter@^5
yarn add @docsearch/docusaurus-adapter@^5
pnpm add @docsearch/docusaurus-adapter@^5
bun add @docsearch/docusaurus-adapter@^5
Keep the adapter in plugins and don't add @docusaurus/theme-search-algolia as another search integration.
3. Move to themeConfig.docsearch
V4 accepted themeConfig.algolia as an alias. V5 rejects it.
- Before: v4
- After: v5
export default {
plugins: ['@docsearch/docusaurus-adapter'],
themeConfig: {
algolia: {
appId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indexName: 'docs',
},
},
};
export default {
plugins: ['@docsearch/docusaurus-adapter'],
themeConfig: {
docsearch: {
appId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indices: [{ name: 'docs' }],
},
},
};
Don't define both keys during the migration. V5 accepts only themeConfig.docsearch.
4. Replace indexName and root search parameters
Move every keyword index into indices. Move root searchParameters onto the matching index:
- Before: v4
- After: v5
docsearch: {
appId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indexName: 'docs',
searchParameters: {
facetFilters: ['language:en'],
attributesToRetrieve: ['content', 'hierarchy', 'type', 'url'],
},
},
docsearch: {
appId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indices: [
{
name: 'docs',
searchParameters: {
facetFilters: ['language:en'],
attributesToRetrieve: ['content', 'hierarchy', 'type', 'url'],
},
},
],
},
indices is required and must contain at least one item. The modal queries all items in order. The search page uses the first item.
5. Replace searchPagePath
V5 replaces the path value with an object that can also configure facets:
- Before: v4
- After: v5
searchPagePath: 'find',
searchPage: {
path: 'find',
facets: [
{ attribute: 'hierarchy.lvl0', label: 'Section' },
{ attribute: 'version', label: 'Version' },
],
},
Use searchPage: false to disable the route. An empty object uses the default search path and the default hierarchy.lvl0 section facet.
6. Move Ask AI to Agent Studio
Create an assistant by following Get started with Agent Studio. V5 accepts only an askAi object and always uses Agent Studio.
- Before: v4
- After: v5
askAi: {
assistantId: 'YOUR_ASSISTANT_ID',
appId: 'ASK_AI_APPLICATION_ID',
apiKey: 'ASK_AI_SEARCH_API_KEY',
indexName: 'docs_markdown',
agentStudio: true,
},
V4 also accepted this shorthand:
askAi: 'YOUR_ASSISTANT_ID',
askAi: {
agentId: 'YOUR_ASSISTANT_ID',
indices: ['docs_markdown'],
},
Remove agentStudio, appId, apiKey, and indexName from askAi. The adapter reuses the root credentials. Without askAi.indices, it uses the first keyword index as the Ask AI index.
V4 supported flat search parameters for the legacy Ask AI backend. V5 requires Agent Studio search parameters keyed by index name:
- Before: v4
- After: v5
askAi: {
assistantId: 'YOUR_ASSISTANT_ID',
searchParameters: {
filters: 'language:en',
attributesToRetrieve: ['title', 'content', 'url'],
},
},
askAi: {
assistantId: 'YOUR_ASSISTANT_ID',
searchParameters: {
docs: {
filters: 'language:en',
attributesToRetrieve: ['title', 'content', 'url'],
},
},
},
Root askAi.searchParameters supports filters, attributesToRetrieve, restrictSearchableAttributes, and distinct.
7. Move the Sidepanel to the root
Move sidePanel out of askAi:
- Before: v4
- After: v5
askAi: {
assistantId: 'YOUR_ASSISTANT_ID',
sidePanel: {
variant: 'inline',
side: 'right',
},
},
askAi: {
assistantId: 'YOUR_ASSISTANT_ID',
},
sidePanel: {
variant: 'inline',
side: 'right',
},
The root sidePanel requires askAi. It can override Agent Studio indices, memory, suggestedQuestions, and translations for the panel. Review hybrid mode for modal and panel behavior.
8. Move custom tools into SearchBar
V5 rejects askAi.tools and sidePanel.tools in docusaurus.config because Docusaurus removes functions while serializing theme config. Swizzle @theme/SearchBar and pass tools as component props.
npm run swizzle -- @docsearch/docusaurus-adapter SearchBar --eject
- React
- JavaScript
import type { DocusaurusSearchBarProps } from '@docsearch/docusaurus-adapter';
import type { ToolCalls } from '@docsearch/react';
import OriginalSearchBar from '@theme-original/SearchBar';
const tools: ToolCalls = {
getReleaseStatus: {
render: ({ message }) => JSON.stringify(message.output),
},
};
export default function SearchBar(props: DocusaurusSearchBarProps) {
return (
<OriginalSearchBar
{...props}
askAi={{ assistantId: 'YOUR_ASSISTANT_ID', tools }}
sidePanel={{ tools }}
/>
);
}
import OriginalSearchBar from '@theme-original/SearchBar';
const tools = {
getReleaseStatus: {
render: ({ message }) => JSON.stringify(message.output),
},
};
export default function SearchBar(props) {
return (
<OriginalSearchBar
{...props}
askAi={{ assistantId: 'YOUR_ASSISTANT_ID', tools }}
sidePanel={{ tools }}
/>
);
}
Include every nested askAi and sidePanel option that you want to keep because component props replace those nested theme-config values. See Agent Studio tools for complete tool definitions.
9. Add v5 search features
Configure modal facets at the docsearch root:
facets: [
{ key: 'language', label: 'Language' },
{ key: 'version', label: 'Version' },
],
Configure search-page facets separately under searchPage.facets. Configure every facet attribute in your Algolia index.
Show a custom hit property in modal results with resultBadgeKey. Add that property to each index's attributesToRetrieve:
indices: [
{
name: 'docs',
searchParameters: {
attributesToRetrieve: [
'content',
'hierarchy',
'type',
'url',
'version',
],
},
},
],
resultBadgeKey: 'version',
10. Verify the migration
Run the production Docusaurus build, then verify these paths:
- Open keyword search with the button,
Ctrl/Cmd+K, and/. - Search every configured index and apply each modal facet.
- Open the search page, apply its facets, and check docs-version filtering.
- Open Ask AI and submit a follow-up question.
- Open the Sidepanel with its button and
Ctrl/Cmd+I. - Check contextual results in every locale and docs version.
- Follow internal, replaced, and external result URLs.
- Check translated strings and result badges.
- Test mobile behavior. Hybrid mode uses the modal instead of the Sidepanel on mobile.
Use the configuration reference to resolve validation messages and review every v5 option.