API Reference
/
React InstantSearch Hooks
/
useAutocomplete()
May. 12, 2022
useAutocomplete()
About this Hook
The useAutocomplete
Hook isn’t currently available in React InstantSearch Hooks, but you can make it yourself using useConnector()
along with connectAutocomplete
.
Refer to the connectAutocomplete
documentation for the full API reference.
If you’re building an autocomplete, you should use the Autocomplete library which lets you build a full-featured, accessible autocomplete experience. This is the recommended way of building an autocomplete search with Algolia.
Examples
Copy
1
2
3
4
5
6
7
8
9
10
11
12
import { useConnector } from 'react-instantsearch-hooks-web';
import connectAutocomplete from 'instantsearch.js/es/connectors/autocomplete/connectAutocomplete';
export function useAutocomplete(props) {
return useConnector(connectAutocomplete, props);
}
export function Autocomplete(props) {
const { indices, currentRefinement, refine } = useAutocomplete(props);
return <>{/* Your JSX */}</>;
}
Did you find this page helpful?