state— aReadonlySignal<QueryState<T>>with{ data, error, isFetching }execute()— runs the query, returnsResult<T, ClientError>subscribe(callback)— reacts to state changes without importing signalsdispose()— cleans up subscriptions and aborts pending requests
client.collection() - Browse collections
Browse products in a collection with filters, sort, and pagination.
| Parameter | Type | Required | Description |
|---|---|---|---|
handle | string | Yes | Collection URL handle |
defaultSort | string | No | Default sort code (uses first configured sort) |
| Parameter | Type | Description |
|---|---|---|
page | number | Page number (default: 1) |
limit | number | Products per page (default: 24) |
sort | string | Sort option code |
filters | unknown | Filter criteria |
signal | AbortSignal | Per-call abort signal |
includeMeta | boolean | Include _meta in response |
linking | Record<string, unknown> | Dynamic linking parameters |
transformRequest | (body) => body | Custom request body transformation |
context | Context | Per-query market/shopper context. Merges with the global client context. See Context. |
client.blocks() - Product recommendations
Product recommendations powered by Layers blocks. Anchored to a product, collection, or cart.
| Parameter | Type | Required | Description |
|---|---|---|---|
blockId | string | Yes | Layers block ID |
anchor | string | No | Anchor product/collection ID, Shopify GID, or handle |
| Parameter | Type | Description |
|---|---|---|
page | number | Page number (default: 1) |
limit | number | Products per page (default: 24) |
filters | unknown | Filter criteria |
signal | AbortSignal | Per-call abort signal |
discounts | DiscountEntitlement[] | Discount entitlements to apply (see below) |
context | Context | Per-query market/shopper context. Merges with the global client context. See Context. |
linking | Record<string, unknown> | Dynamic linking parameters |
transformRequest | (body) => body | Custom request body transformation |
DiscountEntitlement:
productsInCart, geo, customer, and custom.
client.search() - Full-text search
Full-text search with facets. Options persist across calls, so subsequent execute() calls merge with existing options.
| Parameter | Type | Description |
|---|---|---|
query | string | Search query |
page | number | Page number (default: 1) |
limit | number | Products per page (default: 24) |
filters | unknown | Filter criteria |
signal | AbortSignal | Per-call abort signal |
searchId | string | Cached search ID from prepare() |
temporary | boolean | Don’t persist params for next call |
linking | Record<string, unknown> | Dynamic linking parameters |
transformRequest | (body) => body | Custom request body transformation |
context | Context | Per-query market/shopper context. Merges with the global client context. See Context. |
client.suggest() - Predictive search
Predictive search with debouncing and local caching. Only full words (trailing space) are cached. Partial input filters cached results client-side.
| Option | Type | Description |
|---|---|---|
debounce | number | Debounce delay in ms (default: 300) |
excludeInputQuery | boolean | Remove user’s input from suggestions |
excludeQueries | string[] | Custom strings to filter from suggestions |
signal | AbortSignal | Shared abort signal (acts like dispose()) |
client.uploadImage() - Upload image
Upload an image for image-based search.
client.searchByImage() - Search by image
Search products using an uploaded image.
| Parameter | Type | Required | Description |
|---|---|---|---|
imageId | string | Yes | Image ID from uploadImage() |
page | number | No | Page number (default: 1) |
limit | number | No | Products per page (default: 24) |
filters | unknown | No | Filter criteria |
signal | AbortSignal | No | External abort signal |
linking | Record<string, unknown> | No | Dynamic linking parameters |
transformRequest | (body) => body | No | Custom request body transformation |
context | Context | No | Per-query market/shopper context. Merges with the global client context. See Context. |
client.searchContent() - Search articles and blog content
Search articles and blog content with pagination. Options persist across calls, so subsequent execute() calls merge with existing options.
| Parameter | Type | Description |
|---|---|---|
query | string | Search query (required) |
contentType | string | Filter by content type (e.g., ‘article’) |
page | number | Page number (default: 1) |
limit | number | Results per page (default: 24) |
signal | AbortSignal | Per-call abort signal |
transformRequest | (body) => body | Custom request body transformation |
context | Context | Per-query market/shopper context. Merges with the global client context. See Context. |
temporary | boolean | Don’t persist params for next call |
createProductCard() - Product card controller
Reactive controller for product cards with variant selection and availability logic. All derived values are computed signals that auto-update when inputs change. This is a standalone function, not a client method.
| Parameter | Type | Required | Description |
|---|---|---|---|
product | Product | Yes | A product object from a query result |
selectedOptions | ProductOption[] | No | Pre-selected options (e.g. from URL) |
breakoutOptions | ProductOption[] | No | Breakout options that take precedence over selections |
ReadonlySignal):
| Signal | Type | Description |
|---|---|---|
variants | ProductVariant[] | Variants filtered by breakout options |
selectedVariant | ProductVariant | null | Currently selected variant (null if selection is incomplete) |
options | OptionGroup[] | Option groups with availability status baked in |
images | Image[] | Images filtered and ordered by the selected variant/swatch |
price | PriceData | Current price based on selected variant |
priceRange | PriceRangeData | Price range across all available variants |
carouselPosition | number | Current carousel position (1-based) |
isSelectionComplete | boolean | Whether all required options have been selected |
| Method | Description |
|---|---|
selectOption({ name, value }) | Select a single option value by name |
setSelectedOptions([{ name, value }]) | Merge multiple option selections by name |
setSelectedVariant(variantId) | Select a variant directly by numeric ID |
setCarouselPosition(position) | Set carousel position (1-based manual override) |
subscribe(callback) | Subscribe to all state changes. Callback receives ProductCardState. |
dispose() | Clean up subscriptions |
ProductCardState (passed to subscribe callback):
OptionValue.status is computed from inventory and availability data across all variants that match the current selection.
Abort signals
Controllers support two levels of abort:execute() starts.