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

# DocSearchProps

> Configuration interface for the DocSearch component

# DocSearchProps

The `DocSearchProps` interface defines all configuration options for the DocSearch component. This is the primary interface used to configure search behavior, UI customization, AI features, and user interactions.

## Required Properties

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

<ResponseField name="apiKey" type="string" required>
  Public API key with search permissions for the index. This should be a search-only API key, never your admin API key.
</ResponseField>

## Index Configuration

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

  **Deprecated:** `indexName` will be removed in a future version. Please use the `indices` property going forward.
</ResponseField>

<ResponseField name="indices" type="Array<DocSearchIndex | string>">
  List of indices and optional search parameters to be used for search. This allows querying multiple indices or configuring per-index search parameters.

  See the [indices documentation](https://docsearch.algolia.com/docs/api#indices) for more details.

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

    <ResponseField name="name" type="string">
      The name of the Algolia index.
    </ResponseField>

    <ResponseField name="searchParameters" type="SearchParamsObject">
      Optional Algolia search parameters specific to this index.
    </ResponseField>
  </Expandable>

  <CodeGroup>
    ```tsx Single Index theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indices={['docs']}
    />
    ```

    ```tsx Multiple Indices theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indices={[
        'docs',
        'api-reference',
        'blog'
      ]}
    />
    ```

    ```tsx Indices with Search Parameters theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indices={[
        {
          name: 'docs',
          searchParameters: {
            hitsPerPage: 10,
            filters: 'version:v2'
          }
        },
        {
          name: 'api-reference',
          searchParameters: {
            hitsPerPage: 5
          }
        }
      ]}
    />
    ```
  </CodeGroup>
</ResponseField>

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

  **Deprecated:** `searchParameters` will be removed in a future version. Please use the `indices` property going forward.
</ResponseField>

## AI Features

<ResponseField name="askAi" type="DocSearchAskAi | string">
  Configuration or assistant ID to enable Ask AI mode. Pass a string assistant ID for simple configuration, or a full config object for advanced options.

  See [DocSearchAskAi configuration](/api/types/ask-ai-config) for detailed options.

  <CodeGroup>
    ```tsx Simple Configuration theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      askAi="your-assistant-id"
    />
    ```

    ```tsx Advanced Configuration theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      askAi={{
        assistantId: 'your-assistant-id',
        suggestedQuestions: true,
        searchParameters: {
          filters: 'version:latest'
        }
      }}
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="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). This is useful to route Ask AI into a different UI (e.g., `@docsearch/sidepanel-js`) without flicker.

  <Expandable title="InitialAskAiMessage Type">
    ```typescript theme={null}
    type InitialAskAiMessage = {
      query: string;
      messageId?: string;
      suggestedQuestionId?: string;
    };
    ```
  </Expandable>

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      askAi="your-assistant-id"
      interceptAskAiEvent={(initialMessage) => {
        // Route to custom sidepanel
        openCustomSidepanel(initialMessage.query);
        return true; // Prevent default behavior
      }}
    />
    ```
  </CodeGroup>
</ResponseField>

## UI Customization

<ResponseField name="theme" type="DocSearchTheme">
  Theme overrides applied to the modal and related components.

  ```typescript theme={null}
  type DocSearchTheme = 'dark' | 'light';
  ```
</ResponseField>

<ResponseField name="placeholder" type="string">
  Placeholder text for the search input.

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      placeholder="Search documentation..."
    />
    ```
  </CodeGroup>
</ResponseField>

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

  <Expandable title="DocSearchTranslations Type">
    ```typescript theme={null}
    type DocSearchTranslations = Partial<{
      button: ButtonTranslations;
      modal: ModalTranslations;
    }>;
    ```
  </Expandable>

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      translations={{
        button: {
          buttonText: 'Search',
          buttonAriaLabel: 'Search documentation'
        },
        modal: {
          searchBox: {
            resetButtonTitle: 'Clear',
            cancelButtonText: 'Cancel'
          }
        }
      }}
    />
    ```
  </CodeGroup>
</ResponseField>

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

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      portalContainer={document.getElementById('modal-root')}
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="keyboardShortcuts" type="DocSearchModalShortcuts">
  Configuration for keyboard shortcuts. Allows enabling/disabling specific shortcuts.

  **Default:** `{ 'Ctrl/Cmd+K': true, '/': true }`

  <Expandable title="DocSearchModalShortcuts Type">
    ```typescript theme={null}
    interface DocSearchModalShortcuts {
      'Ctrl/Cmd+K'?: boolean;
      '/'?: boolean;
    }
    ```
  </Expandable>

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      keyboardShortcuts={{
        'Ctrl/Cmd+K': true,
        '/': false  // Disable the / shortcut
      }}
    />
    ```
  </CodeGroup>
</ResponseField>

## Search Behavior

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

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      maxResultsPerGroup={8}
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="initialQuery" type="string">
  Query string to prefill when opening the modal.

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      initialQuery="getting started"
    />
    ```
  </CodeGroup>
</ResponseField>

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

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      getMissingResultsUrl={({ query }) => 
        `https://github.com/your-org/docs/issues/new?title=Missing+results+for+${encodeURIComponent(query)}`
      }
    />
    ```
  </CodeGroup>
</ResponseField>

## Custom Components

<ResponseField name="transformItems" type="(items: DocSearchHit[]) => DocSearchHit[]">
  Hook to post-process hits before rendering. Use this to filter, sort, or modify search results.

  See [DocSearchHit type](/api/types/docsearch-hit) for the hit structure.

  <CodeGroup>
    ```tsx Filter Results theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      transformItems={(items) => 
        items.filter(item => item.type !== 'lvl1')
      }
    />
    ```

    ```tsx Modify URLs theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      transformItems={(items) => 
        items.map(item => ({
          ...item,
          url: item.url.replace('http://', 'https://')
        }))
      }
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="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: `(props) => string | JSX.Element | Function`

  <Expandable title="Props Type">
    ```typescript theme={null}
    {
      hit: InternalDocSearchHit | StoredDocSearchHit;
      children: React.ReactNode;
    }
    ```
  </Expandable>

  <Expandable title="Helpers Type">
    ```typescript theme={null}
    {
      html: (template: TemplateStringsArray, ...values: any[]) => any;
    }
    ```
  </Expandable>

  <CodeGroup>
    ```tsx JSX Template theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      hitComponent={({ hit, children }) => (
        <a href={hit.url} className="custom-hit">
          <div className="hit-icon">📄</div>
          {children}
        </a>
      )}
    />
    ```
  </CodeGroup>
</ResponseField>

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

  <Expandable title="Props Type">
    ```typescript theme={null}
    {
      state: AutocompleteState<InternalDocSearchHit>;
    }
    ```
  </Expandable>

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      resultsFooterComponent={({ state }) => (
        <div className="results-footer">
          Found {state.collections.reduce((acc, col) => acc + col.items.length, 0)} results
        </div>
      )}
    />
    ```
  </CodeGroup>
</ResponseField>

## Advanced Configuration

<ResponseField name="transformSearchClient" type="(searchClient: DocSearchTransformClient) => DocSearchTransformClient">
  Hook to wrap or modify the Algolia search client. Useful for adding custom middleware, logging, or request modification.

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

    This is the minimal implementation required for the Algolia search client when using the `transformSearchClient` option.
  </Expandable>

  <CodeGroup>
    ```tsx Add Custom Headers theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      transformSearchClient={(searchClient) => ({
        ...searchClient,
        search(requests) {
          // Add custom headers or modify requests
          return searchClient.search(requests);
        }
      })}
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="navigator" type="AutocompleteOptions<InternalDocSearchHit>['navigator']">
  Custom navigator for controlling link navigation. Use this to integrate with client-side routers or add custom navigation logic.

  <CodeGroup>
    ```tsx Next.js Router theme={null}
    import { useRouter } from 'next/router';

    function Search() {
      const router = useRouter();
      
      return (
        <DocSearch
          appId="YOUR_APP_ID"
          apiKey="YOUR_SEARCH_API_KEY"
          indexName="docs"
          navigator={{
            navigate({ itemUrl }) {
              router.push(itemUrl);
            }
          }}
        />
      );
    }
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="insights" type="AutocompleteOptions<InternalDocSearchHit>['insights']">
  Insights client integration options to send analytics events. This allows tracking user interactions with search results.
</ResponseField>

## User Personalization

<ResponseField name="disableUserPersonalization" type="boolean">
  Disable storage and usage of recent and favorite searches.

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      disableUserPersonalization={true}
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="recentSearchesLimit" type="number">
  Limit of how many recent searches should be saved/displayed.

  **Default:** `7`

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      recentSearchesLimit={10}
    />
    ```
  </CodeGroup>
</ResponseField>

<ResponseField name="recentSearchesWithFavoritesLimit" type="number">
  Limit of how many recent searches should be saved/displayed when there are favorited searches.

  **Default:** `4`

  <CodeGroup>
    ```tsx Example theme={null}
    <DocSearch
      appId="YOUR_APP_ID"
      apiKey="YOUR_SEARCH_API_KEY"
      indexName="docs"
      recentSearchesWithFavoritesLimit={6}
    />
    ```
  </CodeGroup>
</ResponseField>

## Complete Example

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

  function MyApp() {
    return (
      <DocSearch
        appId="YOUR_APP_ID"
        apiKey="YOUR_SEARCH_API_KEY"
        indices={[
          {
            name: 'docs',
            searchParameters: {
              hitsPerPage: 10,
              filters: 'version:latest'
            }
          }
        ]}
        askAi={{
          assistantId: 'your-assistant-id',
          suggestedQuestions: true
        }}
        theme="light"
        placeholder="Search documentation..."
        maxResultsPerGroup={8}
        transformItems={(items) => 
          items.map(item => ({
            ...item,
            url: item.url.replace('http://', 'https://')
          }))
        }
        translations={{
          button: {
            buttonText: 'Search',
            buttonAriaLabel: 'Search documentation'
          }
        }}
        getMissingResultsUrl={({ query }) => 
          `https://github.com/your-org/docs/issues/new?title=Missing+results+for+${encodeURIComponent(query)}`
        }
      />
    );
  }
  ```
</CodeGroup>
