API Reference / React InstantSearch Hooks / useVoiceSearch()

About this Hook

The useVoiceSearch Hook isn’t currently available in React InstantSearch Hooks, but you can make it yourself using useConnector() along with connectVoiceSearch.

Refer to the connectVoiceSearch documentation for the full API reference.

Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { useConnector } from 'react-instantsearch-hooks-web';
import connectVoiceSearch from 'instantsearch.js/es/connectors/voice-search/connectVoiceSearch';

export function useVoiceSearch(props) {
  return useConnector(connectVoiceSearch, props);
}

export function VoiceSearch(props) {
  const {
    isBrowserSupported,
    isListening,
    toggleListening,
    voiceListeningState,
  } = useVoiceSearch(props);

  return <>{/* Your JSX */}</>;
}
Did you find this page helpful?