Skip to main content
The createStorefrontSDK() function accepts a configuration object that controls authentication, network behavior, and debugging.

Configuration Interface

Options Reference

apiUrl

Required. The base URL of the Storefront API. The default and most common value is https://front.rmz.gg/api. This is the production endpoint used by all RMZ stores.

publicKey

Required. Your store’s public key. Found in the store dashboard under API settings. This key is safe to expose in client-side code.

secretKey

Optional. Server-side only. Your store’s secret key. When provided, the SDK generates HMAC-SHA256 signatures for every request. Required for Management API endpoints.
Never include secretKey in client-side code. The SDK will log a warning if it detects a secret key in a browser environment.

environment

Optional. Default: 'production'. Controls environment-specific behavior. In 'development' mode, error messages may be more verbose.

timeout

Optional. Default: 30000 (30 seconds). Maximum time in milliseconds to wait for a response before the request is aborted.

maxRetries

Optional. Default: 3. Number of times to retry a failed request before throwing an error. Retries are triggered on network errors and 5xx server errors.

retryDelay

Optional. Default: 1000 (1 second). Delay in milliseconds between retry attempts.

enableLogging

Optional. Default: false. When enabled, the SDK logs internal operations to the console (initialization, token updates, request details). Useful during development.

Singleton Pattern

The SDK uses a singleton pattern internally. Calling createStorefrontSDK() with the same apiUrl and publicKey returns the same instance:
This prevents redundant initialization and ensures consistent state (auth tokens, cart tokens) across your application.

Environment Variables

Recommended environment variable setup for common frameworks:

Full Example

Error Handling

The SDK throws standard JavaScript errors. Handle them with try/catch: