Use Autocomplete plugins
When using an Autocomplete plugin, all you need to do is provide it with theplugins option.
For example, when using the Insights plugin,
you can instantiate the plugin,
then pass it down to your Autocomplete instance.
JavaScript
Plugins run sequentially, in the order you define them.
Build your own plugin
An Autocomplete plugin is an object that implements theAutocompletePlugin interface.
It can provide sources,
react to state changes,
and hook into various autocomplete lifecycle steps.
It has access to setters,
including the Context API,
allowing it to store and retrieve arbitrary data at any time.
The following example creates a plugin that searches into a static list of GitHub repositories.
JavaScript
JavaScript
JavaScript
The GitHub Search API is rate limited,
which means you need to debounce calls to avoid 403 errors. For instant search results with no rate limiting, highlighted results, flexible custom ranking, and more, you can index repositories into Algolia instead.
Subscribe to source lifecycle hooks
When building, you also get access to thesubscribe method. It runs once when the autocomplete instance starts and lets you subscribe to lifecycle hooks and interact with the instance’s state and context.
For example, suppose you want to build a plugin that sends events to Google Analytics when users navigate results.
You can use subscribe to hook into onSelect and onActive events and use the Google Analytics API there.
JavaScript
Official plugins
-
autocomplete-plugin-recent-searchesDisplays a list of the latest searches the user made. It comes with a pre-implemented version that connects with users local storage. -
autocomplete-plugin-query-suggestionsPlugs Algolia Query Suggestions to your autocomplete. -
autocomplete-plugin-algolia-insightsAutomatically sends click and conversion events to the Algolia Insights API whenever a user interacts with the autocomplete. -
autocomplete-plugin-tagsLets you manage and display tags in the autocomplete. You can use tags for a wide variety of use cases: filtering, displaying refinements, representing navigation steps, and more. -
autocomplete-plugin-redirect-urlLets you redirect your autocomplete results to a specified URL. You can configure this to work for both Algolia and non-Algolia data. For more information, see Redirecting results to a URL.
Reference
A name to identify the plugin.
Type definition
Type definition
Type definition
Type definition
Type definition
data
An extra plugin object to expose properties and functions as APIs.