Skip to main content
Version: Stable (v5.x)

Starlight adapter configuration

Pass options to the adapter in Starlight's plugins:

astro.config.mjs
import starlight from '@astrojs/starlight';
import docsearch from '@docsearch/starlight-adapter';
import { defineConfig } from 'astro/config';

export default defineConfig({
integrations: [
starlight({
title: 'My Docs',
plugins: [
docsearch({
appId: 'YOUR_APPLICATION_ID',
apiKey: 'YOUR_SEARCH_API_KEY',
indices: ['YOUR_INDEX_NAME'],
}),
],
}),
],
});

Compatibility​

DependencySupported version
Astro7.2.10 or later in the 7.x release line
Starlight0.42.7 or later

Root options​

The adapter validates options when Astro starts and rejects unknown options. Options must be JSON-serializable because the adapter passes them to browser code, so functions such as transformItems aren't supported.

appId​

type: string | required

Algolia application ID.

apiKey​

type: string | required

Public API key with search permission. Don't use an admin key.

indices​

type: Array<string | { name: string, searchParameters?: object }> | required

Nonempty list of keyword indices. See Indices and search parameters.

placeholder​

type: string | optional

Search input placeholder. Defaults to Starlight's localized search label.

translations​

type: DocSearchTranslations | optional

Search button and modal text overrides. See Override text.

facets​

type: Array<{ key: string, label?: string }> | optional

Facet controls in the search modal.

maxResultsPerGroup​

type: number | optional

Maximum results shown in each modal result group.

disableUserPersonalization​

type: boolean | optional

Whether to disable recent and favorite searches. Defaults to false.

initialQuery​

type: string | optional

Query placed in the modal when it opens. Defaults to ''.

insights​

type: boolean | { insightsInitParams?: object } | optional

Whether to enable Algolia Insights, or an object that configures it. Defaults to false.

recentSearchesLimit​

type: number | optional

Maximum recent searches when no favorites exist. Defaults to 7.

recentSearchesWithFavoritesLimit​

type: number | optional

Maximum recent searches when favorites exist. Defaults to 4.

keyboardShortcuts​

type: { 'Ctrl/Cmd+K'?: boolean, '/'?: boolean } | optional

Enable or disable the search shortcuts. Both are enabled by default. Configure Ctrl/Cmd+I under Sidepanel options.

resultBadgeKey​

type: string | optional

Hit property rendered as a badge in modal results.

askAi​

type: string | AskAiConfig | optional

Agent Studio agent ID, or an object that configures Ask AI. See Ask AI.

sidePanel​

type: boolean | SidePanelConfig | optional

Whether to enable the Ask AI Sidepanel, or an object that configures it. Requires askAi. See Sidepanel.

Indices and search parameters​

Use a string for an index's default settings or an object for per-index settings:

astro.config.mjs
indices: [
'docs_en',
{
name: 'api_reference',
searchParameters: {
facetFilters: ['version:v5'],
hitsPerPage: 5,
},
},
],

searchParameters accepts Algolia search parameters. The adapter rejects unknown parameter names. Results link to the URLs stored in each index.

The adapter doesn't crawl your site. Create your index with the Algolia Crawler or another tool.

Ask AI​

Pass a string to use an Agent Studio agent with the root credentials:

astro.config.mjs
askAi: 'YOUR_AGENT_ID',

Pass an object for more control:

astro.config.mjs
askAi: {
agentId: 'YOUR_AGENT_ID',
indices: ['docs_en'],
searchParameters: {
docs_en: { facetFilters: ['language:en'] },
},
suggestedQuestions: true,
},

agentId​

type: string | required

Agent Studio agent ID. See Get started with Agent Studio.

appId​

type: string | optional

Application ID for the agent. Defaults to the root appId.

apiKey​

type: string | optional

API key for the agent. Defaults to the root apiKey.

indices​

type: string[] | optional

Index names the agent searches. See Dynamic indices.

searchParameters​

type: Record<string, { facetFilters?, filters?, attributesToRetrieve?, restrictSearchableAttributes?, distinct? }> | optional

Search parameters for each index in indices, keyed by index name.

suggestedQuestions​

type: boolean | optional

Whether to show suggested questions when a conversation starts.

promptSuggestions​

type: { indexName: string, hitsPerPage?: number } | optional

Show prompt suggestions during keyword search. See Prompt suggestions.

The adapter doesn't support the Agent Studio tools and memory options. Tools need functions, and memory needs a per-user token that a static site can't keep private.

Sidepanel options​

Pass true for the default Sidepanel or an object to configure it:

astro.config.mjs
sidePanel: {
buttonVariant: 'inline',
variant: 'inline',
side: 'left',
},

The Sidepanel uses the agent and credentials from askAi.

buttonVariant​

type: 'floating' | 'inline' | optional

'floating' shows a button in the bottom corner. 'inline' shows an icon next to the search button. Defaults to 'floating'.

variant​

type: 'floating' | 'inline' | optional

'floating' overlays the page. 'inline' pushes the page content aside. Defaults to 'floating'.

side​

type: 'left' | 'right' | optional

Side of the page where the Sidepanel opens. Defaults to 'right'.

width​

type: number | string | optional

Sidepanel width. Numbers represent pixels. Defaults to 360px.

expandedWidth​

type: number | string | optional

Expanded Sidepanel width. Numbers represent pixels. Defaults to 580px.

pushSelector​

type: string | optional

CSS selector for the element that the 'inline' variant pushes aside. Defaults to Starlight's main content.

suggestedQuestions​

type: boolean | optional

Override askAi.suggestedQuestions for the Sidepanel.

indices​

type: string[] | optional

Override askAi.indices for the Sidepanel.

translations​

type: SidepanelTranslations | optional

Sidepanel text overrides.

keyboardShortcuts​

type: { 'Ctrl/Cmd+I'?: boolean } | optional

Enable or disable the Sidepanel shortcut. Enabled by default.

Override text​

Override only the modal strings you need:

astro.config.mjs
translations: {
button: {
buttonText: 'Search API docs',
buttonAriaLabel: 'Search API docs',
},
modal: {
searchBox: {
placeholderText: 'Search API docs',
},
},
},

The button text, accessible label, and placeholder default to Starlight's localized search label. Other strings use the DocSearch English defaults. See the React API for every key. Put Sidepanel overrides under sidePanel.translations.

Search component​

The adapter disables Pagefind and renders DocSearch in Starlight's header search slot.

If your configuration already sets components.Search, the adapter keeps your component, leaves Pagefind enabled, and logs a warning. Remove the override to use DocSearch.

Theme​

The search button, modal, and Sidepanel use Starlight's color variables. They follow the light and dark themes and your custom accent colors.

Client-side navigation​

The adapter works with standard page loads and with Astro's ClientRouter.