ais-instant-search
<ais-instant-search index-name="string" :search-client="object" // Optional parameters :on-state-change: function :search-function: function :stalled-search-delay="number" :routing="object" :initial-ui-state="object" :class-names="object" :insights-client: function />
1
2
3
4
5
6
7
8
9
import { AisInstantSearch } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3
export default {
components: {
AisInstantSearch
},
// ...
};
1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
2. This imports all the widgets, even the ones you don’t use. Read the Getting started guide for more information.
About this widget
The ais-instant-search
widget is a wrapper that allows you to configure the credentials for the search. This component automatically provides the search state to all its children.
Note that every other Vue InstantSearch widgets must be wrapped under this one.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<template>
<ais-instant-search
index-name="instant_search"
:search-client="searchClient"
>
<!-- Widgets -->
</ais-instant-search>
</template>
<script>
import algoliasearch from 'algoliasearch/lite';
export default {
data() {
return {
searchClient: algoliasearch(
'YourApplicationID',
'YourSearchOnlyAPIKey'
),
};
},
};
</script>
Props
index-name
|
type: string
Required
The main index in which to search. |
||
Copy
|
|||
search-client
|
type: object
Required
Provides a search client to |
||
Copy
|
|||
search-function
|
type: function
Optional
A hook that is called each time a search needs to be done, with the helper as a parameter.
It’s your responsibility to call When modifying the state of the helper within When this option is set, |
||
Copy
|
|||
on-state-change
|
type: function
Optional
Triggers when the state changes. Whenever you start using this option, the instance becomes controlled. This means that you become responsible for updating the UI state with This can be useful to perform custom logic whenever the state changes. |
||
Copy
|
|||
stalled-search-delay
|
type: number
default: 200
Optional
Defines a time period after which a search is considered stalled. You can find more information in the slow network guide. |
||
Copy
|
|||
routing
|
type: object
default: undefined
Optional
The router configuration used to save the UI state into the URL, or any client-side persistence. You can find more information in the routing guide. The object is accepted if it has either of these keys:
|
||
Copy
|
|||
initial-ui-state
|
type: object
Optional
Adds a |
||
Copy
|
|||
class-names
|
type: object
default: {}
Optional
The CSS classes to override.
|
||
Copy
|
|||
insights-client
|
type: function
Optional
The function exposed by the |
||
Copy
|
HTML output
1
2
3
<div class="ais-InstantSearch">
<!-- Widgets -->
</div>