<InstantSearch>
<InstantSearch indexName={string} searchClient={object} // Optional props initialUiState={object} onStateChange={function} stalledSearchDelay={number} routing={boolean | object} />
1
import { InstantSearch } from 'react-instantsearch-hooks-web';
About this widget
<InstantSearch>
is the root provider component of all widgets and Hooks.
To get you started with React InstantSearch Hooks, you need two parameters:
indexName
: the main index you need to use for your new search UIsearchClient
: the search client to plug to React InstantSearch Hooks
The search client provided by Algolia needs an appId
and an apiKey
. You can find those parameters in your Algolia dashboard.
To get up and running with React InstantSearch Hooks, have a look at the getting started guide.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import React from 'react';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-hooks-web';
const searchClient = algoliasearch(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
function App() {
return (
<InstantSearch indexName="instant_search" searchClient={searchClient}>
{/* Widgets */}
</InstantSearch>
);
}
Props
indexName
|
type: string
Required
The main index to search into. |
||
Copy
|
|||
searchClient
|
type: object
Required
Provides a search client to |
||
Copy
|
|||
initialUiState
|
type: object
Provides an initial state to your React InstantSearch widgets using InstantSearch.js’ |
||
Copy
|
|||
onStateChange
|
type: function
Triggers when the state changes. When using this option, the instance becomes controlled. This means that you become responsible for updating the UI state with This is useful to perform custom logic whenever the state changes. |
||
Copy
|
|||
stalledSearchDelay
|
type: number
default: 200
Defines a time period after which a search is considered stalled. You can find more information in the slow network guide. |
||
Copy
|
|||
routing
|
type: boolean | object
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. |
||
Copy
|