@commerce-blocks/sdk) is an ES module SDK for product discovery powered by 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
Built-in Preact Signals integration for reactive UI updates with automatic caching and request deduplication.
Product Card Controller
Reactive product card management with variant selection, availability logic, and automatic state updates.
Extensibility
Transform products, collections, and search results with custom transforms. Map filter keys for URL-friendly parameters.
Quick Start
Client Methods
The client provides controllers for all Layers storefront APIs:| Method | Description |
|---|---|
client.collection() | Browse and filter products within merchandised collections |
client.search() | Full-text semantic search with prepare/execute flow |
client.suggest() | Predictive search suggestions with debouncing and local caching |
client.blocks() | Product recommendations powered by Layers blocks |
client.uploadImage() | Upload images for image-based search |
client.searchByImage() | Search products using uploaded images |
createProductCard() | Reactive product card with variant selection and availability logic |