Two search requests on page load is often expected behaviour, not a bug, it depends which widgets you're using. Here's how to tell the difference.
When two calls are normal
-
Widgets that need facet counts and results.
refinementListis the common example: one request retrieves the facet values and their counts, a second retrieves the results themselves. -
dynamicWidgets, which adds a query to determine which widgets to render. - Multiple index widgets, such as a results list plus a separate suggestions or categories panel, unless they're bundled into a single multi-query call.
A default InstantSearch template with no faceting makes one API call on page load, which pre-warms the results so subsequent searches feel instant. That single call is expected.
When two calls indicate a problem
If you're only using Algolia to return results after a user submits a query, no faceting, no search-as-you-type, then more than one call on page load means you're sending requests you don't need. Common causes:
- The search client instantiated twice, or a component mounted twice (a frequent React
StrictModeside effect in development). -
searchOnInitialLoador the equivalent left enabled when you don't want results before a query. - An automatic refresh re-running the initial search.
Why this matters for your bill
Every one of these calls is a billable search request, so doubling the page-load count doubles that part of your usage. If you need to bring it down, see How do I reduce my cost while using InstantSearch? and Optimize search request usage.
Where the extra queries are genuinely needed, bundling them into one multi-query call means they cost a single request, see How are multi-queries counted against my search request usage?