@protonagency/commerce-blocks-sdk) is a TypeScript SDK that provides unified APIs for integrating Layers’ AI-powered search and discovery capabilities into your e-commerce applications. It handles data fetching, caching, and reactive state management, allowing you to build rich commerce experiences with minimal boilerplate.
Key Features
The SDK provides a comprehensive set of tools for building commerce experiences:Layers API Integration
Full access to Layers’ search, browse, similar products, 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.
Web Components
Declarative custom elements for data fetching that work with any framework or vanilla JavaScript.
Shopify Integration
Automatic product enrichment by combining Layers search data with fresh Shopify Storefront API data.
Architecture
The SDK is designed as a layered system that separates concerns between data fetching, state management, and UI rendering:Available APIs
The SDK provides access to all Layers storefront APIs:| API | Description |
|---|---|
| Browse | Browse and filter products within merchandised collections |
| Search | Full-text semantic search with typo tolerance and query understanding |
| Similar Products | Find products visually and semantically similar to a reference product |
| Predictive Search | Real-time autocomplete and search suggestions |
| Image Search | Search for products using uploaded images |