Skip to main content
Hosted Checkout provides reactive Vue refs through useCheckout(). No plugin injection or provider component is required.

Installation

Choose the session owner:

Checkout-only Vue app

When the app does not use the Storefront SDK, initialize checkout before mounting the application. Checkout owns authentication and session refresh.
src/main.ts
For development hot-module replacement, clean up the singleton:

Vue app with Storefront SDK

When @commercengine/storefront is present, use provided mode. First send SDK token changes to checkout:
src/lib/storefront.ts
Bootstrap before mounting Vue and send checkout token changes back to the SDK:
src/main.ts

Use the composable

src/components/CartButton.vue
All state values are readonly Vue refs and are automatically unwrapped in templates.
src/components/AddToCartButton.vue
Pass null for a product without variants. For variant products, wait until the selection resolves to a purchasable variant ID.

Nuxt 3

Initialize Hosted Checkout in a client-only plugin. If Nuxt also uses Commerce Engine session APIs, use @commercengine/ssr-utils for request-bound server storage and provided mode for checkout.
plugins/checkout.client.ts
The .client.ts suffix prevents browser-only checkout code from entering the server bundle.

Composable API

Production checklist

Vue and framework starters

Use the production starters to compare SPA behaviour with SSR framework boundaries and deployment configuration.