Learn how to improve your React InstantSearch app when there are no results, when there’s no query, or when there are errors.
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.
This guide describes what to do when there are no results,
when there’s no query,
or when there are errors.
Sometimes, though, users may not get any hits if their device can’t access the network or the network connection is slow.If you want to feature content in your search results based on a set of conditions, you can use Algolia Rules:
If users apply an overly specific configuration, 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
Report incorrect code
Copy
function NoResults() { const { indexUiState } = useInstantSearch(); return ( <div> <p> No results for <q>{indexUiState.query}</q>. </p> <ClearRefinements excludedAttributes={[]} /> </div> );}
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.