Prefer using the Autocomplete widget from InstantSearch instead of the standalone Autocomplete library.
It integrates more closely with your search experience.
For more information,
see the API reference for InstantSearch.js or
React InstantSearch.
Index setup
Before using the query suggestions plugin, you need to create an Algolia with the expected format. You can either use the dashboard, or use the API clients.Installation
First, you need to install the plugin.JavaScript
script element:
HTML
Example
This example uses the plugin withinautocomplete-js,
along with the algoliasearch API client.
JavaScript
JavaScript
Parameters
A function returning Algolia search parameters.
This function takes the original source as a parameter and returns a modified version of that source.Example: change Autocomplete stateUsually, when a link in the Autocomplete menu is selected, the menu closes.
However, to keep the menu visible after a selection is made,
use Example: create linksTurns Query Suggestions into clickable Google search links:
transformSource to set the isOpen state:JavaScript