This page is the curated reference. The complete, generated type reference for the root entry lives at /kit/api/core and is regenerated from the published typings.
@quickbutik/kit and @quickbutik/kit/sdk. On a script-tag page the same function is Quickbutik.createShopkitClient.
A client is cheap. Create one per app in the browser and one per request on the server, because the cookie accessor belongs to that request. See Storage & SSR.
createShopkitClient
ShopkitConfigError synchronously for a malformed key (including a qb_pat_… token), a malformed campaign storefront id, an unknown surface, or two conflicting storefront ids.
ShopkitConfig
OnlypublishableKey is required.
The shop’s publishable key,
qb_pk_<shopPrefix>_<secret>. Safe to ship to a browser. A qb_pat_… personal access token is rejected with a ShopkitConfigError.Commerce API origin. Leave it unset in production. A trailing
/v2 is stripped, since every request path carries its own /v2.Origin of the hosted checkout (checkout-v2). When you set it explicitly it wins over the URL the platform returns for a checkout-v2 handoff. Use it only for a preview environment or a checkout proxied onto your own domain. It is ignored for a shop on the legacy checkout.
Fallback base for image
paths. Rarely needed, because images already arrive with an absolute url. It is the shop-scoped base without the products/ segment, for example https://cdn.quickbutik.com/images/<shopPrefix>.The scopes the key carries, used for a local pre-flight check that throws a named
ShopkitScopeError before the request leaves the process. Pass null to turn the check off. The platform enforces scopes either way. See Errors & scopes.Where the cart id, checkout session id and a logged-in customer’s session are remembered.
auto picks server cookies when cookies is given, then document.cookie, then localStorage, then memory. Resolution never throws; an unusable choice degrades to memory.Server-side cookie access:
get(name), plus optional set(name, value, attributes), remove(name, attributes) and getAll(). Each may return a promise. Supplying it is what lets a server render see the browser’s cart, currency and consent decision. A read-only accessor (only get) is valid; writes are then dropped silently.Cookie consent and the shop’s analytics, on by default.
<ShopkitProvider>, the elements and checkout.start() on a server client all read this one setting, so the browser and the server agree.- An object sets the cookie-policy
revision(default1; bump it to ask every shopper again) and the consentcookieName(defaultqb_consent) for all of them at once. falseturns the whole layer off: no banner, no consent store, no analytics, and nothing appended to hosted checkout URLs.
The currency to browse in (
"EUR", any case) until the shopper picks one with setCurrency(). Every product read and cart request then carries ?currency=, and every checkout session and handoff carries currency. Omitted or null: the shop’s own currency, and nothing is sent. A value that is not a three-letter ISO 4217 code throws a ShopkitConfigError.It is a default, not an override: a choice made with setCurrency() is remembered under ${storageKeyPrefix}_currency and wins on later visits. See Currencies.Bind this client to one campaign storefront (a Säljsida). Product reads are priced for the campaign, carts are created bound to it and checkouts are attributed to it.
surface defaults to "shopkit". Also changes the default storageKeyPrefix. See Campaign storefronts.Shorthand for
storefront: { id }. May be given together with storefront only when both name the same campaign (compared case-insensitively). null and "" mean not set.Prefix for the remembered keys (
qb_cart_id, qb_store_id, qb_checkout_session, qb_checkout_store, qb_currency, qb_customer_session). Defaults to qb_<storefront id lower-cased> on a client bound to a campaign. Change it to run two shops in one browser.Injected fetch, for tests or a framework’s instrumented fetch.
Retries for transient failures (network error, 429, 5xx). Mutations carry an automatic
Idempotency-Key, so a retried POST /cart cannot create a second cart. Do not wrap cart mutations in a retry loop of your own.Extra headers on every request. An
authorization header is ignored; it can never override the key.Called when a request answers 401. Return a fresh key to adopt it and retry the request once. Concurrent 401s share one refresh. Return
null to let the 401 surface. A 401 about the shopper rather than the key (invalid_credentials, an expired customer token) never calls it.How this client treats a logged-in customer’s session.
renew: false uses the access token while it is valid but never renews it; an expired one is treated as a guest for this client’s requests. Renewal is already off on storage that cannot be written (StorageAdapter.writable: false: a cookie accessor without set, or createRequestCookieStorage() without collect), because the rotated refresh token would be lost. See Customer accounts.ShopkitClient
See Cart.
See Checkout.
Customer login, registration, password reset, logout, profile and club points. See Customers below.
The shop’s storage prefix decoded from the key (the CDN folder its images live under). Not the numeric shop id the hosted checkout needs; that one is
cart.storeId.The currency the client browses in: the shopper’s remembered choice, else the configured
currency, else null (the shop’s own). Synchronous. With an async-only cookie accessor (Next’s cookies()) it reports the configured default; requests still read the stored choice. What prices actually came back in is on the response (product.currency, cart.currency).setCurrency
${storageKeyPrefix}_currency, for a year) and notify onCurrencyChange subscribers. null forgets the choice and returns to the configured default. The cart is unchanged: it is priced per request, so the same cart reads in the new currency next time.
Throws a ShopkitConfigError for a value that is not a three-letter code. A well-formed code the shop does not offer is accepted and resolves to the shop’s currency server-side. See Currencies.
onCurrencyChange
currency changes through setCurrency(). Returns an unsubscribe function. The React hooks and the elements use it to refetch prices and re-read the cart. A choice written elsewhere (another tab, a server action, a second client sharing the storageKeyPrefix) changes the next request without firing it.
Customers
X-Customer-Token (the key keeps Authorization), so catalog, cart and checkout are priced for the customer’s group. The kit renews the token before it expires. Every call needs the customer:session scope; config() also accepts storefront:read.
The shop’s settings:
login.enabled, login.signupAllowed, login.hidePricesForGuests, login.hideAddToCartForGuests, customerGroups.enabled, customerClub.enabled and customerClub.joinMethod. Read once per client.Log in and remember the session. Resolves with
{ customer, accessToken, accessTokenExpiresAt, refreshToken, refreshTokenExpiresAt }. Throws a ShopkitAuthError: invalid_credentials, customer_blocked, customer_login_disabled, rate_limited. Logging in as a different customer forgets the cart.Create an account (1.10.0).
{ email, password, firstName, lastName, companyName?, companyNumber?, clubOptIn? }. Resolves with { status: "logged_in", ...session } for a new email, logged in exactly like login(); { status: "verification_required" } for the email of an earlier guest customer, where a code is emailed and resetPassword() finishes the registration; or, rarely, { status: "login_required" } when the account was created but no session could be opened. Throws a ShopkitAuthError: signup_disabled, email_taken, invalid_email, invalid_name, invalid_password, customer_login_disabled, rate_limited. See Registration.Email a one-time reset code (1.10.0) to the account with
{ email }. Resolves the same way whether or not the account exists. The code is valid for 30 minutes, and a new request replaces it. Throws only customer_login_disabled and rate_limited.Set a new password with the emailed code and log in, exactly like
login() (1.10.0). { email, code, password }; the code ignores case, spaces and dashes. Every other session of the customer ends. Throws a ShopkitAuthError: invalid_reset_code, invalid_password, customer_blocked, customer_login_disabled, rate_limited, or password_changed_login_required when the password was changed but no session could be opened. See Password reset.Revoke the session on the platform (best effort), then always forget it locally, with the cart id and the checkout session handle. Never throws.
The profile and
group. null for a guest (no request is made), or when the session ended or changed hands during the read. Concurrent calls share one request.{ member, active, points: { balance, lifetime }, reward: { targetPoints, remaining }, earning: { pointsPerUnit, currency } }, or null for a guest.Adopt a session minted elsewhere:
{ accessToken, refreshToken?, accessTokenExpiresAt?, refreshTokenExpiresAt? }. Without accessTokenExpiresAt, the token’s own exp is used. Rejects with a ShopkitConfigError for an empty token or an unparseable expiry.A valid access token, renewed first when it expires within 30 seconds;
null for a guest or when the session could not be renewed. Also the way to read the session explicitly from async-only storage.Called with
{ customerId, customer } on login and on a newly read profile, and with null on logout or when the session ends. In a browser the same change is dispatched on document as qb:customer, with { customerId } only.Synchronous. With an async-only adapter (Next’s
cookies()) it is false until the session has been read.The profile last returned by
login(), register(), resetPassword() or me() in this client.Who the client’s requests are made for, changing on every login and logout. Key your own caches of customer-priced data on it.
withStorage
cookies accessor, so the adapter you pass is the one used. This is the idiomatic way to reuse one configuration across many server requests: