Getting Started
Learn how to install and configure the SwatBloc SDK to build custom storefronts.
The SwatBloc SDK provides a type-safe interface to your store's backend. It handles authentication, product retrieval, cart management, and checkout flows, allowing you to focus on building the best user experience.
Installation
Install the package via npm, pnpm, or yarn:
npm install @swatbloc/sdkInitialization
Import the client and initialize it with your public API Key. You can find your API key in the Developer tab of your store settings.
store.ts
import { SwatBloc } from '@swatbloc/sdk';
// Initialize the client
// Use pk_live_... for production or pk_test_... for development
export const swat = new SwatBloc(process.env.NEXT_PUBLIC_SWATBLOC_KEY);Note: The SDK is designed to be safe for client-side use. It uses a public key (`pk_live_...` or `pk_test_...`) that only allows safe operations like fetching products and creating carts. Never expose your secret service role keys in frontend code.