Skip to main content

NPM Package

@commercengine/js

Vanilla JavaScript SDK. Use directly via npm or load from the CDN at cdn.commercengine.com/v1.js. No framework dependency.
Add the script tag to your HTML and initialize when it loads:
The async attribute on the script tag is important. It ensures the SDK loads without blocking page rendering. The Commercengine.onLoad callback fires once the script is ready.
The SDK resolves hosted checkout to store-specific subdomains from storeId + environment. Feature flags, login methods, drawer direction, and payment provider are managed in Checkout Studio (Config API), not in SDK init options.

ES Module import

If you’re using a bundler (Vite, Webpack, etc.) but don’t want framework bindings:

Add to cart

Programmatically add items from product pages:
Pass null as the variant ID for products without variants:

Quick Buy

Open checkout directly for a single product (bypasses the cart drawer):

Listening to events

See the Configuration page for the full list of events, methods, and options.