useSearch
call with an empty query scoped to a collection via targetPage: 'collection' and the
collection’s numeric id.
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 — this guide covers only the
collection-page wiring.1. Fetch the collection’s products
CalluseSearch with
targetPage: 'collection', targetId (the numeric Shopify collection id), and
includeFacets so the response carries inline facet counts for the collection.
SearchParams;
the returned data is a SearchResponse
and each products entry is a SearchProduct.
targetId is the numeric collection id. In a Hydrogen collection route you have the
collection GID (gid://shopify/Collection/123) — pass the trailing number (123).2. Render products, sort and pagination
sort accepts the values in SearchSort;
data.pagination is a SearchPagination.
3. Add facet filtering
WithincludeFacets: true, data.facets holds the collection’s facets with live counts.
Track the selected values in state and pass them back as the facets param:
SearchAppliedFacet.
For stable filter definitions (labels, order, swatches — independent of the current
query), fetch them once with
fetchFilters /
app.filters({ collection: collectionId }) and merge in the live counts from
data.facets. See Filters & aggregations.4. Attribute clicks
useSearch returns the track helpers. Fire
trackResultClick with
page_type: 'collection':
SearchTrack.
See also
useSearch— full returns (includingtrackFilter,trackAddToCart)- Search Page — the same call driven by a query
- Search API Reference