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
cart.updateItem
cart.removeItem
cart.delete
Remembered methods
cart.currentId
cart.current
customer_token_required, cart_customer_mismatch), is forgotten and reported as 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, or belongs to another customer, 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.forgetCurrent
add() starts a fresh one. For a cart this shopper can no longer use, such as another customer’s. Use clear() to empty a basket. See Customer accounts.
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.
A cart read on the server. The store then starts
ready, so the first paint matches the server render.subscribe / getSnapshot
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.