Skip to main content
The @docsearch/sidepanel-js package provides a vanilla JavaScript implementation of the DocSearch Ask AI sidepanel. This package is ideal for non-React applications that want to add AI-powered search assistance to their documentation.

Installation

You can also use the CDN version:

sidepanel()

Initializes and mounts a DocSearch Ask AI sidepanel component.

Syntax

Parameters

string | HTMLElement
required
The DOM element or CSS selector where the sidepanel will be mounted.
string
required
Your Algolia application ID.
string
required
Your Algolia search-only API key.
string | DocSearchAskAi
required
Ask AI configuration. Can be a simple assistant ID string or a full configuration object.
Array<string | DocSearchIndex>
Array of Algolia index names to search. Can be strings or objects with index name and search parameters.
'floating' | 'inline'
default:"floating"
Display variant for the sidepanel:
  • floating: Overlays on the right side of the page
  • inline: Embedded in the page layout
string
Placeholder text for the search input.
'light' | 'dark'
Theme mode for the sidepanel UI.
object
Localized strings for the sidepanel UI. See Translations for all available strings.
() => void
Callback invoked when the sidepanel is mounted and ready for interaction.
() => void
Callback invoked when the sidepanel opens.
() => void
Callback invoked when the sidepanel closes.
Window
Custom window object for SSR environments. Defaults to global window.

Return Value

Returns a SidepanelInstance object with methods and properties for programmatic control.

Examples

Basic Usage

With Lifecycle Callbacks

Inline Variant

With Custom Theme and Translations

SidepanelInstance

The interface returned by sidepanel() provides methods and properties for controlling the sidepanel programmatically.

Properties

boolean
Returns true once the component is mounted and ready for interaction. Read-only.
boolean
Returns true if the sidepanel is currently open. Read-only.

Methods

(initialMessage?: InitialAskAiMessage) => void
Opens the sidepanel. Optionally accepts an initial message to start a conversation.
() => void
Closes the sidepanel.
() => void
Unmounts the sidepanel component and cleans up all resources. Call this when removing the sidepanel from your application.

Usage Examples

Open with Initial Question

Check State

Clean Up

TypeScript Types