Signature
Import
You can import this widget in two ways.- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
ais-instant-search
is the root wrapper component for all widgets.
Middleware
Vue InstantSearch provides middleware to help you connect to other systems:-
Insights.
Use the
insights
middleware to send click and conversion events. -
Generic.
With the
middleware
API, you can inject logic into Vue InstantSearch. For example, to send events to Google Analytics.
Examples
Vue
Props
The main index in which to search.
Vue
Provides a search client to
ais-instant-search
.
Read the custom backend guidance
on implementing a custom search client.The client uses a cache to avoid unnecessary search operations,
so you should use a stable reference to the same search client instance rather than creating a new one on each render.
Avoid inlining the function call to algoliasearch
as the prop value in your Vue template.Vue
This option allows you to take control of search behavior.
For example, to avoid doing searches at page load.When this option is set,
search.helper
won’t emit events.
Instead, use on-state-change
or widgets to handle search behavior.A hook is called each time a search is requested (with Algolia’s helper API as a parameter).
Begin searching by calling helper.search()
.When modifying the state of the helper within search-function
, the helper resets the page to 0.
To keep the current page, store the page information, modify the state, and reapply pagination.Triggers when the state changes.
This can be useful when performing custom logic on a state change.When using
on-state-change
, the instance is under your control.
You’re responsible for updating the UI state (with setUiState
).Vue
A time period (in ms) after which the search is considered to have stalled.
Read the slow network guide for more information.
Vue
The router configuration used to save the UI state into the URL or any client-side persistence.For more information, see Sync your URLs.You can’t use
initialUiState
with routing as the two options override each other.- Use
initialUiState
for simple and static use cases. - Use
routing
for anything complex or dynamic.
Vue
Adds a
uiState
to your ais-instant-search
instance,
which provides an initial state to your widgets.Replace YourIndexName
with the name of your Algolia index.Vue
Enables the Insights middleware and loads the
search-insights
library (if not already loaded).
The Insights middleware sends view and click events automatically, and lets you set up your own click and conversion events.
To use this option with an object, refer to the Insights middleware options.Use
insights
instead.This function is exposed by the search-insights
library (usually window.aa
)
and is required if you want to send click and conversion events
with the insights
middleware.Vue
Test new InstantSearch features without affecting others.
HTML output
HTML