This is the React InstantSearch v7 documentation.
If you’re upgrading from v6, see the upgrade guide.
If you were using React InstantSearch Hooks,
this v7 documentation applies—just check for necessary changes.
To continue using v6, you can find the archived documentation.
- Feature specific data from within your records to, for example, show promotional prices during a sales period
- Display advertisements or promotional banners.
To learn how to suppress InstantSearch’s initial search query,
see Conditional requests.
Handling no results
Since not all queries lead to results, it’s essential to let users know when this happens by providing hints on how to adjust the query.Display a message
The easiest way to display a fallback message when a query doesn’t return results is to use theuseInstantSearch()
Hook to create a wrapper component:
React
<InfiniteHits>
or a custom component that uses the useHits()
Hook.
Follow best practices for showing and hiding React InstantSearch widgets
to prevent undesirable additional search requests.
Let users reset filters and facets
If users apply too many filters, they may not find any results. You should account for this by letting them reset filters from the “no results” display so they can start another search. Do this with the<ClearRefinements>
widget.
React
Handling empty queries
By default, InstantSearch always shows you results, even when the query is empty. Depending on your use case and how you build your UI, you may only want to show results when there’s a query.React
Follow best practices for showing and hiding React InstantSearch widgets to prevent undesirable additional search requests.
Handling errors
When an error occurs, you can display a specific piece of content to help users return to the standard state.React