<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.
You need two parameters:
indexName
: your search UI’s main indexsearchClient
: the search client for React InstantSearch Hooks. The search client needs anappId
and anapiKey
: find those credentials in your Algolia dashboard.
The getting started guide will help you get up and running with React InstantSearch Hooks.
Middleware
React InstantSearch Hooks 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 functionality into React InstantSearch Hooks. For example, to send events to Google Analytics.
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 in which to search. |
||
Copy
|
|||
searchClient
|
type: object
Required
Provides a search client to |
||
Copy
|
|||
initialUiState
|
type: object
Provides an initial state to your React InstantSearch Hooks widgets using InstantSearch.js’ |
||
Copy
|
|||
onStateChange
|
type: function
Triggers when the state changes. This can be useful when performing custom logic on a state change. When using |
||
Copy
|
|||
stalledSearchDelay
|
type: number
default: 200
A time period (in ms) after which the search is considered to have stalled. Read the slow network guide for more information. |
||
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
|