React SDK

useSearch

useSearch provides a way to perform a search using the current context or a custom one-off search.

Usage

Returns results for the current query. By default it will use the Variables and Pipeline from the context:

Editable Example
Suggestions
    Powered by

    Optionally pass in Variables or Pipeline:

    Editable Example

    Show

      Multiple searches

      As in the above example, it's possible to perform one off searches using the useSearch hook. This means we can build a page that performs multiple searches, for example within different categories.

      Note: each category search request must use it's own pipeline.

      Editable Example

      Audio

      Loading...

      Computers & Tablets

      Loading...

      TV & Home Theater

      Loading...

      Anatomy

      useSearch returns an object containing the following properties:

      NameTypeDefaultDescription
      resultsResult[]An array of results that met the query.
      latencynumberThe engine latency.
      totalResultsnumberThe total count of results.
      search(q?: string) => voidThe search method, call without param to resend the search request with the current query.
      searchingbooleanIs a search request being processed.
      errorError | nullThe error encountered while searching.

      Parameters

      NameTypeDefaultDescription