> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/algolia/docsearch/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuration

> Configure DocSearch with these options to customize search behavior, appearance, and functionality.

DocSearch accepts configuration options through the `DocSearchProps` interface. Pass these options to the `DocSearch` component to customize its behavior.

## Required Options

<ParamField path="appId" type="string" required>
  Algolia application ID used by the search client.
</ParamField>

<ParamField path="apiKey" type="string" required>
  Public API key with search permissions for the index.
</ParamField>

<ParamField path="indexName" type="string" deprecated>
  Name of the Algolia index to query.

  **Deprecated:** Use `indices` property instead. This will be removed in a future version.
</ParamField>

<ParamField path="indices" type="Array<DocSearchIndex | string>">
  List of indices and optional search parameters to be used for search. Each item can be:

  * A string (index name)
  * A `DocSearchIndex` object with `name` and optional `searchParameters`

  <Accordion title="DocSearchIndex Interface">
    ```typescript theme={null}
    interface DocSearchIndex {
      name: string;
      searchParameters?: SearchParamsObject;
    }
    ```
  </Accordion>

  <CodeGroup>
    ```tsx Simple Usage theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_API_KEY"
      indices={["docs", "blog"]}
    />
    ```

    ```tsx With Search Parameters theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_API_KEY"
      indices={[
        {
          name: "docs",
          searchParameters: {
            facetFilters: ["version:v2"]
          }
        },
        "blog"
      ]}
    />
    ```
  </CodeGroup>
</ParamField>

## Ask AI Configuration

<ParamField path="askAi" type="DocSearchAskAi | string">
  Configuration to enable Ask AI mode. Pass a string assistant ID or a full config object.

  <Accordion title="DocSearchAskAi Interface">
    ```typescript theme={null}
    type DocSearchAskAi = {
      // The assistant ID to use for the ask AI feature
      assistantId: string;
      
      // Optional: Index name for AI search (defaults to main index)
      indexName?: string;
      
      // Optional: API key for AI (defaults to main apiKey)
      apiKey?: string;
      
      // Optional: App ID for AI (defaults to main appId)
      appId?: string;
      
      // Enable suggested questions on new conversation screen
      // Default: false
      suggestedQuestions?: boolean;
      
      // Search parameters for the AI feature
      searchParameters?: AskAiSearchParameters;
      
      // Experimental: Use Agent Studio as chat backend
      agentStudio?: boolean;
    };

    type AskAiSearchParameters = {
      facetFilters?: string[];
      filters?: string;
      attributesToRetrieve?: string[];
      restrictSearchableAttributes?: string[];
      distinct?: boolean | number | string;
    };
    ```
  </Accordion>

  <CodeGroup>
    ```tsx Simple Usage theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_API_KEY"
      indexName="docs"
      askAi="ASSISTANT_ID"
    />
    ```

    ```tsx Full Configuration theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_API_KEY"
      indexName="docs"
      askAi={{
        assistantId: "ASSISTANT_ID",
        suggestedQuestions: true,
        searchParameters: {
          facetFilters: ["type:documentation"]
        }
      }}
    />
    ```
  </CodeGroup>
</ParamField>

<ParamField path="interceptAskAiEvent" type="(initialMessage: InitialAskAiMessage) => boolean | void">
  Intercept Ask AI requests (e.g., submitting a prompt or selecting a suggested question).

  Return `true` to prevent the default modal Ask AI flow (no toggle, no sendMessage). Useful to route Ask AI into a different UI (e.g., sidepanel) without flicker.

  ```typescript theme={null}
  interface InitialAskAiMessage {
    query: string;
    suggestedQuestionId?: string;
    messageId?: string;
  }
  ```
</ParamField>

## Search Customization

<ParamField path="placeholder" type="string">
  Placeholder text for the search input.

  ```tsx theme={null}
  <DocSearch
    placeholder="Search documentation..."
  />
  ```
</ParamField>

<ParamField path="searchParameters" type="SearchParamsObject" deprecated>
  Additional Algolia search parameters to merge into each query.

  **Deprecated:** Use `indices` property instead. This will be removed in a future version.
</ParamField>

<ParamField path="maxResultsPerGroup" type="number">
  Maximum number of hits to display per source/group.

  ```tsx theme={null}
  <DocSearch
    maxResultsPerGroup={5}
  />
  ```
</ParamField>

<ParamField path="transformItems" type="(items: DocSearchHit[]) => DocSearchHit[]">
  Hook to post-process hits before rendering. Useful for filtering, sorting, or modifying search results.

  <CodeGroup>
    ```tsx Filter Results theme={null}
    <DocSearch
      transformItems={(items) => {
        return items.filter(item => 
          !item.url.includes('/deprecated/')
        );
      }}
    />
    ```

    ```tsx Boost Results theme={null}
    <DocSearch
      transformItems={(items) => {
        return items.map(item => ({
          ...item,
          // Boost guides in search rankings
          _rankingInfo: item.type === 'lvl1' && 
            item.hierarchy.lvl0 === 'Guides' 
            ? { ...item._rankingInfo, promoted: true } 
            : item._rankingInfo
        }));
      }}
    />
    ```
  </CodeGroup>
</ParamField>

<ParamField path="transformSearchClient" type="(searchClient: DocSearchTransformClient) => DocSearchTransformClient">
  Hook to wrap or modify the Algolia search client. Useful for adding custom headers, logging, or modifying requests.

  ```typescript theme={null}
  type DocSearchTransformClient = {
    search: LiteClient['search'];
    addAlgoliaAgent: LiteClient['addAlgoliaAgent'];
    transporter: Pick<LiteClient['transporter'], 'algoliaAgent'>;
  };
  ```

  <CodeGroup>
    ```tsx Add Custom Headers theme={null}
    <DocSearch
      transformSearchClient={(searchClient) => {
        searchClient.transporter.headers = {
          ...searchClient.transporter.headers,
          'X-Custom-Header': 'value'
        };
        return searchClient;
      }}
    />
    ```

    ```tsx Log Searches theme={null}
    <DocSearch
      transformSearchClient={(searchClient) => {
        const originalSearch = searchClient.search;
        searchClient.search = async (requests) => {
          console.log('Search requests:', requests);
          const results = await originalSearch(requests);
          console.log('Search results:', results);
          return results;
        };
        return searchClient;
      }}
    />
    ```
  </CodeGroup>
</ParamField>

## Custom Components

<ParamField path="hitComponent" type="(props, helpers?) => JSX.Element">
  Custom component to render an individual hit. Supports multiple template patterns:

  * HTML strings with html helper: `(props, { html }) => html\`<div>...</div>\`\`
  * JSX templates: `(props) => <div>...</div>`
  * Function-based templates

  ```typescript theme={null}
  interface HitComponentProps {
    hit: InternalDocSearchHit | StoredDocSearchHit;
    children: React.ReactNode;
  }

  interface HitComponentHelpers {
    html: (template: TemplateStringsArray, ...values: any[]) => any;
  }
  ```

  <CodeGroup>
    ```tsx JSX Template theme={null}
    <DocSearch
      hitComponent={({ hit, children }) => (
        <a href={hit.url} className="custom-hit">
          {children}
          <span className="hit-badge">{hit.type}</span>
        </a>
      )}
    />
    ```

    ```tsx HTML Template theme={null}
    <DocSearch
      hitComponent={({ hit, children }, { html }) => html`
        <div class="custom-hit" data-type="${hit.type}">
          ${children}
        </div>
      `}
    />
    ```
  </CodeGroup>
</ParamField>

<ParamField path="resultsFooterComponent" type="(props, helpers?) => JSX.Element | null">
  Custom component rendered at the bottom of the results panel. Supports the same template patterns as `hitComponent`.

  ```typescript theme={null}
  interface ResultsFooterProps {
    state: AutocompleteState<InternalDocSearchHit>;
  }
  ```

  ```tsx theme={null}
  <DocSearch
    resultsFooterComponent={({ state }) => (
      <div className="results-footer">
        Found {state.context.nbHits} results
      </div>
    )}
  />
  ```
</ParamField>

## User Personalization

<ParamField path="disableUserPersonalization" type="boolean" default={false}>
  Disable storage and usage of recent and favorite searches.

  ```tsx theme={null}
  <DocSearch
    disableUserPersonalization={true}
  />
  ```
</ParamField>

<ParamField path="recentSearchesLimit" type="number" default={7}>
  Limit of how many recent searches should be saved and displayed.
</ParamField>

<ParamField path="recentSearchesWithFavoritesLimit" type="number" default={4}>
  Limit of how many recent searches should be saved and displayed when there are favorited searches.
</ParamField>

## Navigation & Behavior

<ParamField path="initialQuery" type="string">
  Query string to prefill when opening the modal.

  ```tsx theme={null}
  <DocSearch
    initialQuery="getting started"
  />
  ```
</ParamField>

<ParamField path="navigator" type="AutocompleteOptions['navigator']">
  Custom navigator for controlling link navigation. Useful for integrating with client-side routers.

  ```tsx theme={null}
  <DocSearch
    navigator={{
      navigate({ itemUrl }) {
        // Use your router instead of default navigation
        router.push(itemUrl);
      }
    }}
  />
  ```
</ParamField>

<ParamField path="getMissingResultsUrl" type="({ query }: { query: string }) => string">
  Builds a URL to report missing results for a given query.

  ```tsx theme={null}
  <DocSearch
    getMissingResultsUrl={({ query }) => 
      `https://github.com/myorg/docs/issues/new?title=Missing results for: ${query}`
    }
  />
  ```
</ParamField>

<ParamField path="keyboardShortcuts" type="DocSearchModalShortcuts" default={{ 'Ctrl/Cmd+K': true, '/': true }}>
  Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.

  ```typescript theme={null}
  type DocSearchModalShortcuts = {
    'Ctrl/Cmd+K'?: boolean;
    '/'?: boolean;
  };
  ```

  <CodeGroup>
    ```tsx Disable Slash Shortcut theme={null}
    <DocSearch
      keyboardShortcuts={{
        'Ctrl/Cmd+K': true,
        '/': false
      }}
    />
    ```

    ```tsx Disable All Shortcuts theme={null}
    <DocSearch
      keyboardShortcuts={{
        'Ctrl/Cmd+K': false,
        '/': false
      }}
    />
    ```
  </CodeGroup>
</ParamField>

## Theming & Display

<ParamField path="theme" type="DocSearchTheme">
  Theme overrides applied to the modal and related components. Accepts `'dark'` or `'light'`.

  See [Theme Options](/api/theme-options) for more details.

  ```tsx theme={null}
  <DocSearch
    theme="dark"
  />
  ```
</ParamField>

<ParamField path="translations" type="DocSearchTranslations">
  Localized strings for the button and modal UI.

  See [Translations](/api/translations) for all available translation strings.

  ```tsx theme={null}
  <DocSearch
    translations={{
      button: {
        buttonText: 'Rechercher',
        buttonAriaLabel: 'Rechercher'
      },
      modal: {
        searchBox: {
          placeholderText: 'Rechercher dans la documentation'
        }
      }
    }}
  />
  ```
</ParamField>

<ParamField path="portalContainer" type="DocumentFragment | Element">
  The container element where the modal should be portaled to. Defaults to `document.body`.

  ```tsx theme={null}
  <DocSearch
    portalContainer={document.getElementById('modal-root')}
  />
  ```
</ParamField>

## Analytics

<ParamField path="insights" type="AutocompleteOptions['insights']">
  Insights client integration options to send analytics events.

  ```tsx theme={null}
  <DocSearch
    insights={{
      insightsClient: window.aa,
      onItemsChange({ insights, insightsEvents }) {
        const events = insightsEvents.map((event) => ({
          ...event,
          eventName: 'Hits Viewed'
        }));
        insights.viewedObjectIDs(...events);
      }
    }}
  />
  ```
</ParamField>

## Usage Example

<CodeGroup>
  ```tsx Basic Configuration theme={null}
  import { DocSearch } from '@docsearch/react';

  function App() {
    return (
      <DocSearch
        appId="YOUR_APP_ID"
        apiKey="YOUR_SEARCH_API_KEY"
        indexName="docs"
      />
    );
  }
  ```

  ```tsx Advanced Configuration theme={null}
  import { DocSearch } from '@docsearch/react';

  function App() {
    return (
      <DocSearch
        appId="YOUR_APP_ID"
        apiKey="YOUR_SEARCH_API_KEY"
        indices={[
          {
            name: "docs_v2",
            searchParameters: {
              facetFilters: ["version:v2"]
            }
          },
          "blog"
        ]}
        askAi={{
          assistantId: "ASSISTANT_ID",
          suggestedQuestions: true
        }}
        placeholder="Search docs or ask AI..."
        maxResultsPerGroup={5}
        transformItems={(items) => {
          return items.filter(item => 
            !item.url.includes('/deprecated/')
          );
        }}
        navigator={{
          navigate({ itemUrl }) {
            router.push(itemUrl);
          }
        }}
        translations={{
          button: {
            buttonText: 'Search'
          }
        }}
      />
    );
  }
  ```
</CodeGroup>
