Skip to main content
Hosted Checkout exposes a readable checkout store and fine-grained stores for common state.

Installation

Choose the authentication mode first:

Checkout-only Svelte app

Initialize and destroy checkout from the root lifecycle:
src/App.svelte

Svelte app with Storefront SDK

For a browser Svelte application using the Storefront SDK, configure SDK-to-checkout token updates inside session, then initialize checkout in provided mode.
src/lib/storefront.ts
src/App.svelte

SvelteKit

Use the first-party @commercengine/storefront/sveltekit wrapper when the SvelteKit application uses the Storefront SDK. It aligns browser and request-cookie sessions. Follow SvelteKit SDK integration for the complete provided-mode pattern. For a checkout-only SvelteKit site, initialize managed mode inside onMount and destroy it in onDestroy:
src/routes/+layout.svelte
Do not initialize browser-only checkout code during module evaluation or server rendering.

Use the store

src/lib/CartButton.svelte
src/lib/AddToCartButton.svelte
Pass null for simple products; resolve a valid variant ID before enabling the button for variant products.

Fine-grained stores

Use the individual stores when a component only needs one value:
Available fine-grained stores include cartCount, cartTotal, isReady, and isOpen.

Store API

Production checklist

SvelteKit production starters

Review native SvelteKit storefront implementations for load boundaries, prerendering, session bootstrap, search races, SEO, and deployment patterns.