Skip to main content
This guide describes what to do when there are no results, when there’s no query, or when there are errors. If results haven’t loaded, the search may still be in progress or the device may be offline. For more information, see No hits or is the search still in progress? If you want to feature content in your search results based on a set of conditions, you can use Algolia Rules to:
To learn how to suppress InstantSearch’s initial , see Conditional requests.

Handle searches without results

When a query doesn’t return results, display a message and suggest changing the query or clearing filters.

Display a message

To display a fallback message when a query doesn’t return results, use the templates.empty option.
All examples in this guide assume you’ve included InstantSearch.js in your web page from a CDN. If, instead, you’re using it with a package manager, adjust how you import InstantSearch.js and its widgets for more information.
JavaScript
The preceding example also works with infiniteHits.

Let users reset filters and facets

If users apply an overly specific configuration, they may not find any results. 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. However, you can’t use it inside the empty template, so must use routing instead. First, activate the URL sync mechanism:
JavaScript
Routing makes your InstantSearch app aware of changes in the URL. By removing URL parameters, you can influence search parameters and reset filters and facets.
JavaScript

Handle empty queries

By default, InstantSearch sends search requests even when the query is empty. To hide results until users enter a query, use the following code. This hides the results without preventing search requests.

Using transformItems

Using transformItems to display no results when the query is empty:
JavaScript

Using a connector

The following example uses the connectHits connector.
JavaScript

Handle search errors

If an error occurs, you can display a specific piece of content to help users return to the standard state.

Making an error-handling widget

You can build a custom widget to handle errors. If you want to learn more about custom widgets, check out the guide.
JavaScript
You can improve this custom widget by writing a more meaningful error message, adapting it to your UI, figuring out if users are online, and logging the error in your monitoring system.
Last modified on October 8, 2026