Skip to main content
The DocSearchInstance interface is returned by the docsearch() function and provides methods and properties for programmatic control of the DocSearch component.

Interface Definition

Properties

isReady

boolean
Returns true once the DocSearch component is mounted and ready for interaction.This property is true immediately after the component is rendered to the DOM.
Example:

isOpen

boolean
Returns true if the search modal is currently open.Useful for checking modal state before performing actions or syncing UI state with the modal.
Example:

Methods

open()

() => void
Opens the search modal.If the modal is already open, this method has no effect.
Example:
Usage with Custom Triggers:

close()

() => void
Closes the search modal.If the modal is already closed, this method has no effect. Automatically refocuses the search button trigger after closing.
Example:

openAskAi()

(initialMessage?: InitialAskAiMessage) => void
Opens Ask AI mode in the modal.Requires Ask AI to be configured in the docsearch() options via the askAi parameter.
Parameters:
InitialAskAiMessage
Optional initial message to pre-populate the Ask AI interface.
Examples:

destroy()

() => void
Unmounts the DocSearch component and cleans up all resources.After calling this method:
  • The component is removed from the DOM
  • All event listeners are cleaned up
  • isReady returns false
  • All other methods become no-ops
Example:
Framework Integration Examples:

Complete Usage Example

TypeScript Types