DocsReferenceFunctionsusePredictiveSearch

usePredictiveSearch

The usePredictiveSearch function is a React hook used to show search results as the user types.

Usage

import { usePredictiveSearch } from "builderoo";
 
const { results, query, setQuery, loading } = usePredictiveSearch({types: ["product"]})

Parameters

NameTypeDescription
typesstring[]One or more of product, collection, article

Return Values

NameTypeDescription
resultsSearchResult*The search results.
querystringCurrent search query. Used to show query in the search box or elsewhere.
setQueryfunctionUsed to set the search query as the user types.
loadingbooleanIf the search is currently loading

*In predictive search only _id, title, route and image properties are available.