Skip to main content
The RMZ Storefront SDK is a TypeScript-first, framework-agnostic library that wraps the Storefront API into a clean, type-safe interface. Use it with React, Vue, Angular, Svelte, or vanilla JavaScript in both client-side and server-side environments.

GitHub Repository

Source code, issues, and releases.

Next.js Starter

Full example storefront built with Next.js and the SDK.

Features

  • HMAC-SHA256 authentication with automatic signature generation for server-to-server requests
  • Firebase/Supabase-style query builder with intuitive method chaining
  • Universal compatibility — works in browsers, Node.js, Web Workers, and React Native
  • TypeScript first with full type safety and IntelliSense
  • Automatic retry, caching, and request deduplication
  • Singleton pattern for efficient resource usage
  • ~15 KB gzipped, zero external runtime dependencies, tree-shakeable

Installation

npm install rmz-storefront-sdk
The current version is 2.1.2. The package is published as rmz-storefront-sdk on npm.

Quick Start

Client-side (browser)

On the client side, only a publicKey is needed. The default API URL points to https://front.rmz.gg/api.
import { createStorefrontSDK } from 'rmz-storefront-sdk';

const sdk = createStorefrontSDK({
  publicKey: 'pk_your_public_key_here',
  apiUrl: 'https://front.rmz.gg/api', // default, can be omitted
  environment: 'production'
});

// Fetch store information
const store = await sdk.store.get();

// Browse products with the query builder
const featured = await sdk.products
  .where('featured', '=', true)
  .orderBy('created_at', 'desc')
  .limit(8)
  .get();

// Add a product to the cart
const cart = await sdk.cart.addItem(productId, 2);

Server-side (Node.js / SSR)

On the server, provide both publicKey and secretKey to enable HMAC-SHA256 authentication for every request.
import { createStorefrontSDK } from 'rmz-storefront-sdk';

const sdk = createStorefrontSDK({
  publicKey: process.env.RMZ_PUBLIC_KEY!,
  secretKey: process.env.RMZ_SECRET_KEY!, // enables HMAC signatures
  apiUrl: 'https://front.rmz.gg/api',
  environment: 'production'
});

const store = await sdk.store.get();
const products = await sdk.products.getAll({ per_page: 100 });
Never expose your secretKey in client-side code. It must only be used in server-side environments (Node.js, SSR, API routes).

SDK Modules

The SDK exposes the following namespaces on the instance returned by createStorefrontSDK():
NamespaceDescriptionAuth Required
sdk.storeStore info, currencies, settings, features, bannersNo
sdk.productsProduct listing, search, query builder, related productsNo
sdk.categoriesCategory listing and category productsNo
sdk.cartCart management, coupons, validation, summaryNo (uses cart token)
sdk.checkoutCreate checkout sessions, get payment resultsNo
sdk.authOTP login, registration, profile managementPartial
sdk.ordersOrder history, subscriptions, coursesYes
sdk.wishlistWishlist add/remove/checkYes
sdk.reviewsStore reviews, submit product reviewsPartial
sdk.coursesCourse access, progress tracking, module completionYes
sdk.pagesStatic pagesNo
sdk.componentsHomepage componentsNo
sdk.managementAnalytics, inventory, exports (server-side only)Secret key
sdk.customTokensGenerate, list, revoke, and validate API tokensYes

Environment Detection

The SDK automatically detects its runtime environment and adjusts behavior:
import { Environment } from 'rmz-storefront-sdk';

console.log(Environment.info);
// { isServer: false, isBrowser: true, isWebWorker: false, isNode: false, platform: 'browser' }
  • Browser: Uses X-Client-Auth header, warns if secretKey is present.
  • Node.js: Generates HMAC-SHA256 signatures on every request when secretKey is provided.
  • React Native: Treated as a browser environment.

Health Check

Verify API connectivity at any time:
const health = await sdk.healthCheck();
if (health.status === 'ok') {
  console.log('API is reachable');
} else {
  console.error('API error:', health.message);
}

Next Steps

Authentication

Understand the HMAC security model and key management.

Configuration

All configuration options, environment variables, and defaults.

Products

Query builder, search, and product retrieval.

Framework Guides

React, Vue, Angular, and vanilla JS examples.