NPM Package
@commercengine/checkout
Vue integration for Commerce Engine Checkout.
Installation
Setup
CallinitCheckout once at your app’s entry point. The SDK resolves the hosted URL from storeId + environment using store-specific subdomains:
main.ts
Use the composable
useCheckout() returns reactive refs and action methods. Call it inside setup() or <script setup>.
CartButton.vue
Full example
App.vue
Nuxt
For Nuxt 3, create a plugin to initialize checkout:plugins/checkout.client.ts
.client.ts suffix ensures this only runs in the browser. Then use useCheckout() in any component.
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.Syncing external auth
AuthSync.vue
Composable API reference
useCheckout() returns:
| Property | Type | Description |
|---|---|---|
isReady | Readonly<Ref<boolean>> | true when the checkout iframe is loaded |
isOpen | Readonly<Ref<boolean>> | true when the overlay is visible |
cartCount | Readonly<Ref<number>> | Number of items in the cart |
cartTotal | Readonly<Ref<number>> | Cart subtotal |
cartCurrency | Readonly<Ref<string>> | Currency code |
isLoggedIn | Readonly<Ref<boolean>> | Whether a user is logged in |
user | Readonly<Ref<UserInfo | null>> | Current user info |
openCart() | function | Open the cart drawer |
openCheckout() | function | Open checkout directly |
close() | function | Close the overlay |
addToCart(productId, variantId, quantity?) | function | Add an item to the cart |
updateTokens(accessToken, refreshToken?) | function | Sync auth tokens |