<Configure>
This is the React InstantSearch v7 documentation. React InstantSearch v7 is the latest version of React InstantSearch and the stable version of React InstantSearch Hooks.
If you were using React InstantSearch v6, you can upgrade to v7.
If you were using React InstantSearch Hooks, you can still use the React InstantSearch v7 documentation, but you should check the upgrade guide for necessary changes.
If you want to keep using React InstantSearch v6, you can find the archived documentation.
<Configure {...searchParameters} />
1
import { Configure } from 'react-instantsearch';
About this widget
<Configure>
is a renderless component that lets you forward search parameters to Algolia.
Any prop you pass to this component is forwarded as a search parameter to Algolia.
Don’t make the widget itself conditional, for example, in a ternary statement. Doing so creates an infinite loop.
You can also create your own UI with
useConfigure()
.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import React from 'react';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
import { InstantSearch, Configure } from 'react-instantsearch';
const searchClient = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
function App() {
return (
<InstantSearch indexName="instant_search" searchClient={searchClient}>
<Configure
analytics={false}
filters="free_shipping:true"
hitsPerPage={40}
/>
</InstantSearch>
);
}
Props
...searchParameters
|
type: SearchParameters
A list of search parameters to enable. |
||
Copy
|
Hook
React InstantSearch let you create your own UI for the <Configure>
widget with useConfigure()
. Hooks provide APIs to access the widget state and interact with InstantSearch.
The useConfigure()
Hook accepts parameters and returns APIs.
Usage
First, create your React component:
import { useConfigure } from 'react-instantsearch';
function CustomConfigure(props) {
const { refine } = useConfigure(props);
return null;
}
Then, render the widget:
<CustomConfigure {...searchParameters} />
Parameters
Hooks accept parameters. You can pass them manually, or forward the props from your custom component.
When you provide a function to Hooks, make sure to pass a stable reference to avoid rendering endlessly (for example, with useCallback()
). Objects and arrays are memoized; you don’t need to stabilize them.
...searchParameters
|
type: SearchParameters
A list of search parameters to enable. It returns an object with a |
||
Copy
|
APIs
Hooks return APIs, such as state and functions. You can use them to build your UI and interact with React InstantSearch.
refine
|
type: (value: SearchParameters) => void
Replaces the provided search parameters with new ones. |
||
Copy
|
Example
1
2
3
4
5
6
7
8
import React from 'react';
import { useConfigure } from 'react-instantsearch';
function CustomConfigure(props) {
useConfigure(props);
return null;
}