Documentation Index
Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt
Use this file to discover all available pages before exploring further.
Controller state
All controllers expose reactive state via aReadonlySignal<QueryState<T>>:
Query result
Collection, search, blocks, and image search controllers all return the same baseQueryResult shape in data:
priceRange requires { name: 'Price', code: 'variants.price' } in your facets configuration. Without it, priceRange will be undefined.
Blocks result
Blocks results extendQueryResult with block metadata:
Suggestions result
Thesuggest controller returns a different shape:
Content search result
ThesearchContent controller returns articles:
Product types
Product
TheProduct type represents a fully built product returned by the SDK. It extends ProductBase and can be further extended via the transforms.product configuration.
CommerceBlocksID is a string in the format layers-{numericId}. ProductGID is a Shopify Global ID string like gid://shopify/Product/123.
ProductVariant
VariantGID is a Shopify Global ID string like gid://shopify/ProductVariant/456.
Price and PriceRange
formatted value is generated by the SDK using the formatPrice function you provide at client init, or a default formatter based on Intl.NumberFormat.
Image and FeaturedMedia
Options
RichProductOption is used for the product’s top-level options array. It includes the attribute code (the internal Layers identifier) and an optional swatch with color or image data if defined for that option.
ProductCategory
NamedTag
Error handling
All methods return{ data, error } instead of throwing. Errors are discriminated by _tag:
Error types
NetworkError
Raised when a request fails before receiving a response.ApiError
Raised when the Layers API returns an error response.ValidationError
Raised when pre-request validation fails (for example, a required parameter is missing or out of range).ConfigError
Raised duringcreateClient() when the SDK is misconfigured.
Retry helpers
isRetryable classifies errors by tag, code, and status. Use it standalone or as a shouldRetry predicate:
NetworkError with code TIMEOUT, CONNECTION_FAILED, or DNS_FAILED, and ApiError with code RATE_LIMITED or SERVICE_UNAVAILABLE.
Error type guard
isClientError can be used to check whether an unknown value is one of the SDK error types:
Exported types
The SDK exports all types from@commerce-blocks/sdk: