Skip to main content

NPM Package

@commercengine/checkout

Svelte integration for Commerce Engine Checkout.

Installation

Setup

Call initCheckout once in your root layout or entry file. The SDK resolves the hosted URL from storeId + environment using store-specific subdomains:
+layout.svelte
Feature flags, login methods, drawer direction, and payment provider are managed in Checkout Studio (Config API), not as SDK init options. Use theme only for per-session overrides.

Use the store

Import the checkout readable store and access it with $checkout:
CartButton.svelte

Fine-grained stores

For components that only need a single value, use the individual stores to minimize re-renders:
CartBadge.svelte
Available individual stores: cartCount, cartTotal, isReady, isOpen.

Full example

App.svelte

SvelteKit

For SvelteKit, initialize in the root layout. The SDK is client-only and safely no-ops during SSR.
src/routes/+layout.svelte
If your SvelteKit app also uses the @commercengine/storefront SDK, you must use authMode: "provided" with two-way token sync instead of the standalone example above. See SvelteKit SDK Integration for the full pattern.

Store API reference

The checkout store value contains: