This page is the curated reference. The complete, generated type reference lives at /kit/api/core (the resource) and /kit/api/react (
CartStore), regenerated from the published typings.CartStore, the observable cart the React hooks and the web components share.
The cart is server-owned and prices are recomputed on every read. Never cache cart figures beyond the current render. All money is in minor units. Shapes are on Types.
Currency
A cart stores no currency of its own: it is priced per request. Every cart call (create, get, addItem, updateItem, removeItem, and so current, ensure and add) carries the client’s currency as ?currency=, so the same cart reads in SEK on one request and in EUR on the next. Switching currency never creates a new cart and never loses a line.
cart.currencyis what every amount in that response is in. Format with it, never a constant.cart.presentmentsays how that currency relates to the checkout:{ mode, chargeCurrency, baseCurrency, exchangeRate }. In"display"mode the amounts are converted for display and the checkout chargeschargeCurrency(the shop’s own). A missingpresentmentmeansmode: "base".
Stateless methods
cart.create
storefrontId creates a cart bound to that campaign storefront; the binding cannot change afterwards. Check it out with checkout.start({ cartId }).
cart.get
null on 404 or 410: an expired cart is a normal answer.
cart.addItem
string | number
required
"prod_123" or 123.number
The variant’s numeric id. Required when the product has more than one variant.
number
default:"1"
cart.updateItem
cart.removeItem
cart.delete
Remembered methods
cart.currentId
cart.current
null. Use it wherever a missing cart is a legitimate answer: a header badge, a server-rendered cart page, any page a crawler can reach.
cart.ensure
cart.add
ensure() plus addItem(). It also recovers once from a stale cart: when the remembered id answers 404 or 410 it forgets it, creates a fresh cart and retries. Prefer it over ensure() followed by addItem().
On a client bound to a campaign storefront the cart it creates is bound too. A per-call storefrontId here must equal the client’s binding, or the call throws a ShopkitConfigError before any request. See Campaign storefronts.
cart.clear
add() starts a fresh basket.
The remembered checkout session id and the shop’s store id are left alone, so a thank-you page can still confirm an order already paid for.
fallbackCartId names the cart to delete when storage remembers none (the cart on screen).
CartStore
useSyncExternalStore. Without React, take the page’s instance from the elements’ configure() (configure(...).cartStore) or Quickbutik.cart on a script-tag page rather than constructing a second one.
ShopkitClient
required
Cart | null
A cart read on the server. The store then starts
ready, so the first paint matches the server render.subscribe / getSnapshot
Cart | null
'idle' | 'loading' | 'ready' | 'error'
Error | null
Captured from the last failed mutation. Mutations do not throw.
number
Mutations in flight.
number
Sum of quantities, for a badge.
number
Bumped once per successful mutation made through this store, never by a load or refresh. Compare it across renders; the absolute value means nothing.
load
cart.current(). Never creates a cart, so mounting a badge causes no write for a visitor who only browses.
refresh
add / updateItem / removeItem
null on failure, with the error in the snapshot. add() creates the cart on first use. updateItem(itemId, 0) is translated into a remove.
clear / clearCart
cart.clear(). A no-op (no request, no revision bump) when there is no cart.
buyNow
cart. It does not navigate; the UI layers do.
onMutation
load, refresh or hydrate (something was read, nothing changed), nor for a failed mutation. It is what the analytics hub diffs into add_to_cart and remove_from_cart.
'add' | 'update' | 'remove' | 'clear' | 'buy-now'
Cart | null
The cart before the change.
Cart | null
The cart after the change;
null after clear.