InstantSearch
<InstantSearch indexName={string} searchClient={object} // Optional parameters searchState={object} resultsState={object} createURL={function} onSearchStateChange={function} onSearchParameters={function} refresh={boolean} stalledSearchDelay={number} />
1
import { InstantSearch } from 'react-instantsearch-dom';
About this widget
We released React InstantSearch Hooks, a new InstantSearch library for React. We recommend using React InstantSearch Hooks in new projects or upgrading from React InstantSearch.
InstantSearch
is the root component of all React InstantSearch implementations. It provides to all the connected components (or widgets) a way to interact with the searchState
.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-dom';
const searchClient = algoliasearch(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
const App = () => (
<InstantSearch
indexName="instant_search"
searchClient={searchClient}
>
{/* Widgets */}
</InstantSearch>
);
Props
indexName
|
type: string
Required
The main index in which to search. |
||
Copy
|
|||
searchClient
|
type: object
Required
Provides a search client to |
||
Copy
|
|||
searchState
|
type: object
Optional
Injects a |
||
Copy
|
|||
resultsState
|
type: object
Optional
Injects the results that are used at first rendering. Those results are found by using the |
||
Copy
|
|||
createURL
|
type: function
Optional
This function is called when |
||
Copy
|
|||
onSearchStateChange
|
type: function
Optional
This function is called on every |
||
Copy
|
|||
onSearchParameters
|
type: function
Optional
This function is called every time search parameters are updated, usually by a widget. Use it to collect search parameters as widgets update them, and this is what the library uses internally for server-side rendering. |
||
Copy
|
|||
refresh
|
type: boolean
Optional
Use this option to decide if you should clear the cache when the index changes (to update the frontend). |
||
Copy
|
|||
stalledSearchDelay
|
type: number
default: 200
Optional
A time period (in ms) after which the search is considered to have stalled. This value impacts the prop |
||
Copy
|