@commerce-blocks/sdk) is an ES module SDK for product discovery powered by the Layers API. It provides reactive state management, built-in caching, and a unified interface for browse, search, recommendations, and image search.
Key features
Layers API integration
Full access to Layers’ search, browse, recommendations, blocks, and image search APIs with built-in error handling.
Reactive state management
Framework-agnostic reactive controllers with
subscribe() for automatic UI updates and in-flight request deduplication.Product card controller
Reactive product card management with variant selection, availability logic, and automatic state updates.
Extensibility
Transform products, collections, search, blocks, and other responses with custom transforms. Build filters with a type-safe DSL.
Quick start
SDK methods
The SDK returns controllers for all Layers storefront APIs:Architecture
The SDK uses a controller pattern where each method returns a controller with reactive state and aget() method. All controllers support two ways to consume state:
Next steps
Installation
Learn how to install and configure the SDK in your project.
API reference
Explore the complete API reference for all SDK methods.
Framework integration
Patterns for React, Vue, Svelte, Lit, Alpine.js, and vanilla JS.
Error handling
Learn how to handle errors gracefully with the Result pattern.