Skip to main content
Signature

Import

See this widget in action

Preview this widget and its behavior.

About this widget

The voiceSearch widget lets users perform a voice-based . It uses the Web Speech API, which only Chrome (from version 25) has implemented so far. This means the voiceSearch widget only works on desktop Chrome and Android Chrome. It doesn’t work on iOS Chrome, which uses the iOS WebKit.

Examples

JavaScript

Options

string | HTMLElement
required
The CSS Selector or HTMLElement to insert the widget into.
boolean
default:false
Whether to trigger the search as you speak. If false, search is triggered only after speech is finished. If true, search is triggered whenever the engine delivers an interim transcript.
JavaScript
string
default:"all languages"
The language you want your voiceSearch widget to recognize. The default (all languages) can result in false positives. For example, an English word you pronounce might be recognized as a French word, which can cause irrelevant results. Make sure to give a BCP 47 language tag, like en-US or fr-FR. This language is automatically forwarded to the queryLanguages query parameter.
JavaScript
function
A function that receives the current query and returns the list of search parameters you want to enable for voice search.By default, the following query parameters are set:To disable this behavior, override the return value of additionalQueryParameters.
JavaScript
object
The templates to use for the widget.
JavaScript
object
The CSS classes you can override:
  • root. The root element of the widget.
  • button. The button element.
  • status. The status element.
JavaScript

Templates

You can customize parts of a widget’s UI using the Templates API. Each template includes an html function, which you can use as a tagged template. This function safely renders templates as HTML strings and works directly in the browser—no build step required. For details, see Templating your UI.
The html function is available in InstantSearch.js version 4.46.0 or later.
string | function
The template used for displaying the button.
string | function
The template used for displaying the status.

HTML output

HTML

Customize the UI with connectVoiceSearch

If you want to create your own UI of the voiceSearch widget, you can use connectors. To use connectVoiceSearch, you can import it with the declaration relevant to how you installed InstantSearch.js.
Then it’s a 3-step process:
JavaScript

Create a render function

This rendering function is called before the first search (init lifecycle step) and each time results come back from Algolia (render lifecycle step).
JavaScript

Render options

boolean
true if user’s browser supports voice search.
JavaScript
function
Starts listening to user’s speech, or stops it if already listening.
JavaScript
boolean
true if listening to user’s speech.
JavaScript
boolean
An object containing the following states regarding speech recognition:
  • status: string. Current status (initial|askingPermission| waiting|recognizing|finished|error).
  • transcript: string. Currently recognized transcript.
  • isSpeechFinal: boolean. true if speech recognition is finished.
  • errorCode: string | undefined. An error code (if any). Refer to the spec for more information.
JavaScript
object
All original widget options forwarded to the render function.
JavaScript

Create and instantiate the custom widget

First, create your custom widgets using a rendering function. Then, instantiate them with parameters. There are two kinds of parameters you can pass:
  • Instance parameters. Predefined options that configure Algolia’s behavior.
  • Custom parameters. Parameters you define to make the widget reusable and adaptable.
Inside the renderFunction, both instance and custom parameters are accessible through connector.widgetParams.
JavaScript

Instance options

boolean
default:false
Whether to trigger the search as you speak. If false, search is triggered only after speech is finished. If true, search is triggered as many times as the engine delivers an interim transcript.
JavaScript
string
default:"all languages"
The language you want your voiceSearch widget to recognize. The default (all languages) can result in false positives. For example, an English word you pronounce might be recognized as a French word, which can cause irrelevant results. Make sure to give a BCP 47 language tag, like en-US or fr-FR. This language is automatically forwarded to the queryLanguages query parameter.
JavaScript
function
A function that receives the current query and returns the list of search parameters you want to enable for voice search.By default, the following query parameters are set:To disable this behavior, override the return value of additionalQueryParameters.
JavaScript

Full example

Last modified on July 22, 2026