Skip to main content
A search results page is a useSearch call driven by the shopper’s query, with facets, sort, pagination and attribution.
Prerequisite: the search app is registered (.use(search())), your app is wrapped in <GloodProvider>, and https://search.glood.ai is in your CSP connectSrc. See Installation.
Read the query from the URL and pass it to useSearch. Set includeFacets to get inline facet counts for the current query.
Params are a SearchParams; data is a SearchResponse and products are SearchProduct objects.

2. Render results, sort and pagination

sort values are listed in SearchSort; data.pagination is a SearchPagination.

3. Add facet filtering

Track selected facet values in state and pass them as the facets param (an array of SearchAppliedFacet). Render the buckets from data.facets:
For stable filter definitions independent of the query, fetch them with fetchFilters, and for standalone live counts use fetchFilterAggregations.

4. Attribution

useSearch returns trackSearch, trackResultView, trackResultClick, trackAddToCart and trackFilter. Call trackSearch when the results render, trackResultClick on click (step 2), and trackAddToCart on add. Each takes a SearchTrack. Standard Shopify events (search_submitted, product_viewed, …) are forwarded automatically — see Events & attribution.

5. (Optional) Server-render the first page

To ship results in the initial HTML, call fetchSearchResults in the route loader instead of the hook:

See also