> ## Documentation Index
> Fetch the complete documentation index at: https://quickbutik.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# React

> Every provider, hook and headless component exported from @quickbutik/kit/react.

> [!NOTE]
>
> This page is the curated reference. The complete, generated type reference lives at [/kit/api/react](https://quickbutik.dev/kit/api/react.md) and is regenerated from the published typings. For a walkthrough, start with [React setup](https://quickbutik.dev/kit/react/setup.md).

```ts theme={null}
import { ShopkitProvider, useCart, ProductProvider } from "@quickbutik/kit/react"
```

Every export is a client hook or client component; the entry carries a `"use client"` directive. React is an optional peer dependency, `^18.2 || ^19`. The `slug`, `id` and promise forms of `<ProductProvider>`, and `<SEO />` tag hoisting, need React 19.

The components render **no markup of their own**: no wrapper, no class names. The exceptions are `<ProductImage />` (one `<img>`), `<Checkout>` (one `<div>` holding the frame), the SEO components (head tags), and the consent banner's default dialog and `<ConsentSettingsButton>` (which render only when you give them no content of your own).

## Providers and context

### ShopkitProvider

```tsx theme={null}
<ShopkitProvider config={{ publishableKey }} initialCart={cart}>{children}</ShopkitProvider>
<ShopkitProvider client={shopkit}>{children}</ShopkitProvider>
```

Makes one client and one shared [`CartStore`](https://quickbutik.dev/kit/reference/cart) available to the tree. Both are created once and kept for the provider's lifetime. By default it also mounts cookie consent, the default banner and the shop's own analytics, gated on the shopper's decision (see the `consent` prop).

**config** `ShopkitConfig`

A plain config object, which can cross a server-to-client boundary. Read once, not a render dependency. See [Client](https://quickbutik.dev/kit/reference/client.md).

**client** `ShopkitClient`

A client you built yourself. Takes precedence over `config`.

**initialCart** `Cart | null`

A cart read on the server. The store starts `ready`, so SSR and the first client paint agree.

**storefrontId** `string | null`

Sell the whole tree into one campaign storefront. Changing it rebuilds the client and the cart store. With a prebuilt `client`, it must match that client's binding or it throws.

**currency** `string | null`

Shorthand for `config.currency`: the currency to browse in until the shopper picks one, so a **default**, not an override. A later change switches the same client with `setCurrency()` without rebuilding it: catalog hooks refetch and the same cart is re-read. A change to `null` returns to the value the provider **mounted** with, not necessarily the shop's own currency; mount with no `currency` if `null` should mean the shop's own. With a prebuilt `client` the mount-time value is ignored (give the client its `currency`) and only later changes are forwarded. See [Currencies](https://quickbutik.dev/kit/concepts/currencies.md).

**consent** `ShopkitConsentOptions | false`

Shapes the cookie consent and analytics the provider mounts, which are **on by default**. It does not switch them off: the one switch is `consent: false` in the client `config`, which a server client's checkout handoff reads too. `consent={false}` on the prop still turns consent off for this tree, but is **deprecated** and warns, because a server-started checkout cannot see it.

**ShopkitConsentOptions**

**initialState** `ConsentState | null`

The decision as the server read it (`await shopkit.consent.read()`), so the first paint shows the right banner state with no flash. Without it the banner waits for hydration.

**lang** `string | null`

Language of the built-in copy (`en`, `sv`, `da`, `nb`, `fi`), for the banner and every `<ConsentSettingsButton>` below. Set it when rendering on the server.

**privacyPolicyUrl** `string | null`

Adds a "Privacy policy" link to the banner.

**labels** `Partial\<ConsentLabels\>`

Overrides for any of the banner's built-in strings.

**banner** `boolean | (state: ConsentBannerState) =\> ReactNode` (default: true)

`false` renders no banner (render your own with `<ConsentBanner>` or `useConsent()`); a function is rendered in the default banner's place.

**unstyled** `boolean`

Leave out the default banner's stylesheet.

**className** `string`

Extra class on the default banner's root.

**analytics** `boolean | AnalyticsProviderOptions` (default: true)

`false` keeps the banner and loads no pixel; an object takes the `<AnalyticsProvider>` options (extra `destinations`, `auto: false`, `requireConsent`, `loadBeforeConsent`, …).

**store** `ConsentStore`

A store you built yourself; the store options are then ignored.

**revision / cookieName / maxAgeDays / domain / sameSite / secure / persist** `ConsentStoreOptions`

The consent store's options. Prefer setting `revision` and `cookieName` once in `config.consent`, where the server read and the checkout handoff see them too.

A provider nested inside another (a campaign provider inside the site's) reuses the outer consent store, banner and analytics hub. See [Consent and analytics](https://quickbutik.dev/kit/concepts/consent-and-analytics.md).

**children** `ReactNode` *required*

### useShopkit / useShopkitContext

```ts theme={null}
useShopkit(): ShopkitClient
useShopkitContext(): { client: ShopkitClient; cartStore: CartStore }
```

Both throw a `ShopkitConfigError` when there is no provider above. `ShopkitContext` is exported for advanced composition.

## Cart

### useCart

```ts theme={null}
const { cart, itemCount, status, pending, error, revision, add, updateItem, removeItem, clear, clearCart, refresh } = useCart()
```

Every caller shares the same store. The cart is loaded on first mount and **never created speculatively**. It is re-read on every currency switch and every customer login or logout; a cart bound to another customer is forgotten, so the next `add()` starts a fresh one.

**cart** `Cart | null`

**itemCount** `number`

Sum of quantities, for a badge.

**status** `'idle' | 'loading' | 'ready' | 'error'`

**pending** `number`

Mutations in flight.

**error** `Error | null`

Captured, not thrown.

**revision** `number`

Bumped once per successful mutation made through the store.

**add(item)** `Promise\<Cart | null\>`

`{ productId, variantId?, quantity? }`. `null` on failure.

**updateItem(itemId, quantity)** `Promise\<Cart | null\>`

Line id. `0` removes the line.

**removeItem(itemId)** `Promise\<Cart | null\>`

**clear()** `Promise\<void\>`

Deletes the remembered cart and forgets it. `clearCart` is an alias.

**refresh()** `Promise\<Cart | null\>`

## Catalog hooks

All return `AsyncState<T>`: `{ data: T | null; loading: boolean; error: Error | null; refetch(): void }`. They refetch when the client's currency changes and when a customer logs in or out, so group prices follow the customer. Each fetch is aborted on unmount and on every re-run, and a superseded response is discarded, so a search-as-you-type box cannot land an out-of-order result. They are not a cache; an app with TanStack Query or SWR should call the client directly.

### useProducts

```ts theme={null}
useProducts(params?: { limit?; cursor?; storefrontId?; currency? }, options?: { enabled?: boolean; initialData?: Page<Product> | null }): AsyncState<Page<Product>>
```

The product hooks follow the client's currency and **refetch when it changes**. A `currency` parameter prices one read in another currency (`null` for the shop's own).

### useProductSearch

```ts theme={null}
useProductSearch(params?: ProductSearchParams, options?: { enabled?; initialData? }): AsyncState<Page<Product>>
```

Takes every [`products.search`](https://quickbutik.dev/kit/reference/products) parameter. All are primitives, so an inline object literal does not re-fetch.

### useProduct

```ts theme={null}
useProduct(productId: string | number | null | undefined, options?: { initialData?: Product | null; storefrontId?: string | null; currency?: string | null }): AsyncState<Product | null>
```

`data` is `null` for a hidden or missing product.

### useCategories

```ts theme={null}
useCategories(params?: CategoryListParams, options?: { enabled?; initialData? }): AsyncState<Page<Category>>
```

### useShop

```ts theme={null}
useShop(options?: { initialData?: Shop | null }): AsyncState<Shop>
```

## Currency

### useCurrency

```ts theme={null}
const { currency, selected, baseCurrency, currencies, mode, rate, chargeCurrency, setCurrency, isLoading, error } = useCurrency()
```

The currency the tree browses in, what the shop offers, and the switch. Reads the shop once per client (shared by every caller; needs `checkout:read`). See [Currencies](https://quickbutik.dev/kit/concepts/currencies.md).

**currency** `string | null`

What prices are shown in: the choice when the shop offers it, else the shop's own.

**selected** `string | null`

What was asked for (the remembered choice, else the configured default), whether or not the shop offers it.

**baseCurrency** `string | null`

The shop's own currency.

**currencies** `ShopCurrency[]`

`{ code, mode, rate }[]`, base first. Only the base entry when the converter is off; empty while loading.

**mode** `'base' | 'display' | 'charge'`

`display`: shown converted, charged in the shop's currency. `charge`: priced and charged in it.

**rate** `number`

Units of `currency` per 1 unit of the shop's currency.

**chargeCurrency** `string | null`

What the checkout will charge.

**setCurrency(code)** `Promise\<void\>`

Switch and remember. Every product hook refetches, `useCart()` re-reads the same cart, and the next checkout opens in it. `null` returns to the default.

**isLoading** `boolean`

True while the shop, and with it the list of currencies, is loading.

**error** `Error | null`

```tsx theme={null}
function CurrencySwitcher() {
  const { currency, currencies, setCurrency } = useCurrency()
  if (currencies.length < 2) return null
  return (
    <select value={currency ?? ""} onChange={(e) => setCurrency(e.target.value)}>
      {currencies.map((c) => <option key={c.code} value={c.code}>{c.code}</option>)}
    </select>
  )
}
```

### useClientCurrency

```ts theme={null}
useClientCurrency(client: ShopkitClient): string | null
```

The bare subscription: `client.currency`, re-rendering when it changes. No shop read.

### useAsync

```ts theme={null}
useAsync<T>(operation: (signal: AbortSignal) => Promise<T>, deps: readonly unknown[], options?: { enabled?; initialData? }): AsyncState<T>
```

The primitive the catalog hooks are built on, for a read of your own with the same abort semantics.

## Customer accounts

### useCustomer

```ts theme={null}
const { customer, isLoggedIn, loading, error, login, register, requestPasswordReset, resetPassword, logout, refresh } = useCustomer()
```

The logged-in customer, with login, registration, password reset and logout. Re-renders on every login, logout and newly read profile. When it finds a session without a profile (after a reload, or `setSession()`), it reads the profile once. See [Customer accounts](https://quickbutik.dev/kit/concepts/customer-accounts.md#react).

**customer** `Customer | null`

The profile, or `null` for a guest or before it is read.

**isLoggedIn** `boolean`

**loading** `boolean`

True while a login, registration, password reset, logout or profile read is in flight.

**error** `Error | null`

The last failure of any of those calls, typically a `ShopkitAuthError`. Cleared by the next attempt.

**login(input)** `Promise\<CustomerSession\>`

`{ email, password }`. Rejects with the `ShopkitAuthError` (`invalid_credentials`, `customer_blocked`, …) and also puts it on `error`.

**register(input)** `Promise\<CustomerRegisterResult\>`

Create an account (1.10.0). Resolves with `status``logged_in` (logged in), `verification_required` (an earlier guest's email: ask for the emailed code and call `resetPassword`) or, rarely, `login_required`. Rejects with the `ShopkitAuthError` (`email_taken`, `invalid_password`, `signup_disabled`, …), also on `error`.

**requestPasswordReset(input)** `Promise\<void\>`

`{ email }`. Emails a reset code (1.10.0). Resolves whether or not the account exists; rejects only with `customer_login_disabled` or `rate_limited`, also on `error`.

**resetPassword(input)** `Promise\<CustomerSession\>`

`{ email, code, password }`. Sets the new password and logs in (1.10.0). Rejects with the `ShopkitAuthError` (`invalid_reset_code`, `invalid_password`, `password_changed_login_required`, …), also on `error`.

**logout()** `Promise\<void\>`

Logs out and forgets the cart, which `useCart()` picks up. Never rejects.

**refresh()** `Promise\<Customer | null\>`

Re-read the profile (`customers.me()`).

In an httpOnly-cookie setup the browser cannot see the session, so `useCustomer()` reports a guest there. Render account UI on the server.

### useCustomerClub

```ts theme={null}
useCustomerClub(): AsyncState<CustomerClub | null>
```

The logged-in customer's club membership and points. `data` is `null` for a guest, and nothing is fetched. Refetched on login and logout. On a shop without the club, `error` is a `ShopkitAuthError` with `code: "customer_club_disabled"`.

```tsx theme={null}
const { data: club } = useCustomerClub()
club?.member && <p>{club.points.balance} points, {club.reward.remaining} to the next reward</p>
```

### useClientCustomerKey

```ts theme={null}
useClientCustomerKey(client: ShopkitClient | null): string
```

The bare subscription: `client.customers.cacheKey`, re-rendering on every login and logout. List it as a dependency of your own data hooks so they refetch for the new customer.

## Product and variant selection

### ProductProvider

```tsx theme={null}
<ProductProvider product={product}>…</ProductProvider>          // resolved
<ProductProvider product={promiseForProduct}>…</ProductProvider> // React 19 use()
<ProductProvider slug="cotton-tee">…</ProductProvider>           // looks it up
<ProductProvider id="prod_27">…</ProductProvider>                // one request
```

Holds the variant selection for one product and derives everything from it. Renders nothing of its own. A `slug` or `id` lookup re-reads the product when the client's currency changes. With analytics on, it tracks `view_item` once per product.

**product** `Product | Promise\<Product | null\> | null`

A resolved product, or a promise unwrapped with React 19 `use()` (wrap in `<Suspense>`). Takes precedence over `slug` and `id`.

**slug** `string`

Looks the product up. Walks the catalog; needs React 19 and a `<ShopkitProvider>`.

**id** `string | number`

Looks the product up by id. Needs React 19 and a `<ShopkitProvider>`.

**notFound** `ReactNode`

Rendered when the product is missing or hidden.

**initialVariantId** `number`

Preselect a variant, for `?variant=` deep links.

**selectFirstAvailable** `boolean` (default: false)

Start on the first non-hidden variant instead of a price range.

**currency** `string`

A formatting fallback, used only when the product does not state its own `product.currency` (a platform older than the field). Passed through to `useProductPrice` and `<SEO />`.

**onVariantChange** `(variant: ProductVariant | null) =\> void`

**children** `ReactNode` *required*

### useProductState

```ts theme={null}
useProductState(): ProductState
useOptionalProductState(): ProductState | null // outside a provider
```

**product** `Product`

**options** `VariantOptionGroupState[]`

Each group with its values, `selected` and `available`.

**selection** `Record\<number, number\>`

**selectedVariant** `ProductVariant | null`

**isComplete** `boolean`

The selection pins one variant.

**hasOptions** `boolean`

**price** `VariantPriceState`

`amount`, `compareAtAmount`, `min`, `max`, `isRange`.

**currency** `string | undefined`

The product's own `product.currency`, else the provider's `currency` prop. Format with this.

**select(optionId, valueId)** `void`

Repairs contradictions instead of refusing.

**clear(optionId)** `void`

**reset()** `void`

**selectVariant(variantId)** `void`

### Selection hooks

| Hook | Returns |
| - | - |
| `useProductOptions()` | `VariantOptionGroupState[]` |
| `useProductOption(idOrName)` | One group by id or name, or `null` |
| `useSelectedVariant()` | `ProductVariant \| null` |
| `useProductPrice()` | `VariantPriceState & { currency?: string }` |

### useProductAddToCart

```ts theme={null}
const { addToCart, canAddToCart, pending, error, missingOptions, buyNow, buying, buyNowError } = useProductAddToCart()
```

**addToCart(quantity?)** `Promise\<Cart | null\>`

Adds the selected variant. A no-op while the selection is incomplete.

**canAddToCart** `boolean`

False until one variant is pinned, while a mutation is in flight, and during a buy-now.

**pending** `number`

**error** `Error | null`

**missingOptions** `VariantOptionGroupState[]`

The groups still missing a choice, for a "Select a size" prompt.

**buyNow(input, quantity?)** `Promise\<void\>`

Adds the selected variant and navigates to the hosted checkout. `input` is a `StartCheckoutInput`.

**buying** `boolean`

True while a buy-now runs, and after it navigated until the page is restored.

**buyNowError** `Error | null`

### Headless components

Each renders **only** what its `children` function returns.

| Component | Props | Child receives |
| - | - | - |
| `<ProductOptions>` | `children` | `VariantOptionGroupState[]` |
| `<ProductOptionGroup>` | `option` (id or name), `fallback?` | `VariantOptionGroupState` |
| `<ProductOptionValues>` | `option` (id or name), `fallback?` | `VariantOptionValueState`, once per value |
| `<SelectedVariant>` | `fallback?` | `ProductVariant` |
| `<ProductPrice>` | | `VariantPriceState & { currency? }` |
| `<AddToCart>` | | `ProductAddToCartState` (the `useProductAddToCart` result) |
| `<ProductConsumer>` | | `ProductState` |

`fallback` renders when the product has no such group, so a component written for "Color" degrades quietly.

```tsx theme={null}
<ProductOptionValues option={group.id}>
  {(value) => (
    <button key={value.id} aria-pressed={value.selected} aria-disabled={!value.available} onClick={() => select(group.id, value.id)}>
      {value.name}
    </button>
  )}
</ProductOptionValues>
```

## Images

### ProductImage

```tsx theme={null}
<ProductImage width={800} height={800} priority />          // inside <ProductProvider>
<ProductImage product={product} width={400} height={400} /> // a card
<ProductImage image={image} product={product} width={120} /> // a gallery
<ProductImage productId="prod_27" width={64} />              // fetches; needs <Suspense>
```

Renders a single `<img>` with the CDN URL and `srcSet` resolved. Product precedence: `image`, `product`, the surrounding `<ProductProvider>`, then a lookup by `productId` or `slug`.

**width** `number`

CSS pixels. Drives the resize, the `srcSet` and the box.

**height** `number`

**index** `number` (default: 0)

Which image, in display order.

**imageId** `number`

A specific image, for example `variant.imageId`.

**densities** `number[]` (default: \[1, 2])

`[]` disables the `srcSet`.

**widths** `number[]`

`w` descriptors instead; pair with `sizes`.

**transform** `ImageTransform`

`quality`, `format`, `fit`, `crop` and so on.

**alt** `string`

Defaults to the image's alt text, then the product name, then `""`.

**fallback** `ReactNode`

Rendered when there is no image. Never a broken `<img>`.

**priority** `boolean`

`loading="eager"` and `fetchPriority="high"`, for the LCP image. Everything else lazy-loads.

**includePending** `boolean` (default: false)

**cacheBust** `boolean` (default: true)

**product / image / productId / slug** `various`

Which product and image; see above.

Every other `<img>` attribute passes through.

### useProductImage

```ts theme={null}
const { src, srcSet, alt, image, product, width, height } = useProductImage({ width: 800 })
```

The same resolution without rendering, for `next/image`, a CSS background or an og:image.

## Checkout

### useCheckout

```ts theme={null}
const { start, redirectToCheckout, buyNow, starting, error, url } = useCheckout()
```

**start(input)** `Promise\<StartCheckoutResult | null\>`

Creates the session without navigating.

**redirectToCheckout(input)** `Promise\<void\>`

Creates the session and navigates with `location.assign`.

**buyNow(item, input)** `Promise\<void\>`

Adds one item to the remembered cart and navigates.

**starting** `boolean`

True while starting, and after a navigation until the page is restored from the back/forward cache. A navigation that never unloads releases it after 10 seconds.

**error** `Error | null`

**url** `string | null`

The last handoff URL.

A second click while one is in flight is ignored. `input` is a [`StartCheckoutInput`](https://quickbutik.dev/kit/reference/checkout); pass `cartId: cart?.id` from `useCart()` where cookies may be blocked (an app builder's preview).

### useOrderConfirmation

```ts theme={null}
const { status, orderNumber, outcome, confirmation, loading, error } = useOrderConfirmation(sessionId?, options?)
```

Polls until the order exists, the payment fails terminally, or the caps are reached. Without a `sessionId` it uses the one the kit remembered when the checkout started. With analytics on, a completed order is reported as the `purchase` event once, deduplicated across reloads.

**enabled** `boolean` (default: true)

`false` never polls.

**initialConfirmation** `SessionConfirmation | null`

The snapshot the server already took with `shopkit.checkout.confirmation()`. A `completed` or `failed` one is final: nothing is polled, the bought cart and session are forgotten (as a completed poll does), and a completed one is reported as the `purchase`. A pending one is polled from.

**trackPurchase** `boolean` (default: true)

Report the `purchase` event once the order exists.

```tsx theme={null}
// The server read a snapshot; a settled one renders final on the first paint.
const { status, orderNumber } = useOrderConfirmation(sessionId, { initialConfirmation })
```

**status** `'completed' | 'processing_payment' | 'no_attempt' | 'failed' | null`

**orderNumber** `number | null`

**outcome** `ConfirmationOutcome | null`

`timeout` is not a failure.

**confirmation** `SessionConfirmation | null`

**loading** `boolean`

**error** `Error | null`

For example "no checkout session to confirm" on a direct visit.

### Checkout

```tsx theme={null}
<Checkout successUrl="/success" backUrl="/cart" lang="sv" onComplete={({ orderNumber }) => track(orderNumber)} />
```

The hosted checkout rendered inline in an iframe. Renders one `<div>` with the frame inside. The session is created once, on mount; changing props afterwards does not rebuild it. It follows the cart: nothing mounts for an empty cart, and emptying the cart takes the frame down. See [Embedded checkout](https://quickbutik.dev/kit/concepts/embedded-checkout.md).

**successUrl** `string`

Relative URLs resolve against the page. Only the origin is used for the landing.

**backUrl** `string`

**lang** `string`

**theme** `'light' | 'dark'`

Omitted, the checkout follows the merchant's setting.

**confirmation** `'redirect' | 'inline'` (default: redirect)

**minHeight** `number` (default: 600)

**className** `string`

**style** `CSSProperties`

**onReady** `(detail: \{ sessionId, shopId, step \}) =\> void`

**onStep** `(detail: \{ step \}) =\> void`

**onEvent** `(detail: \{ name, params \}) =\> void`

**onComplete** `(detail: \{ sessionId, orderNumber, successUrl \}) =\> void`

**onError** `(detail: \{ code, message, fatal \}) =\> void`

A checkout that could not start is reported here, never thrown.

**onFallback** `(detail: \{ reason, url \}) =\> void`

**onEmpty** `() =\> void`

Called once when the cart settles empty.

## Consent and analytics

`<ShopkitProvider>` mounts all of this by default; the pieces are public for a page that composes them itself. See [Consent and analytics](https://quickbutik.dev/kit/concepts/consent-and-analytics.md).

### ConsentProvider

```tsx theme={null}
<ConsentProvider revision={2} lang="sv">{children}</ConsentProvider>
```

Provides one consent store to the tree. Takes every `ConsentStoreOptions` field (`revision`, `cookieName`, `maxAgeDays`, `domain`, `sameSite`, `secure`, `persist`, `initialState`), plus `store` (a `ConsentStore` you built, for example one bridged to a third-party consent platform with `persist: false`) and `lang`. A `<ConsentProvider>` inside one that already exists shares the existing store: one decision per page.

### useConsent / useOptionalConsent

```ts theme={null}
const { status, analytics, marketing, open, allows, acceptAll, rejectAll, save, reset, openSettings, closeSettings, store } = useConsent()
useOptionalConsent() // the same, or null without a consent provider
```

**status** `'undecided' | 'decided'`

Undecided is treated as denied.

**analytics / marketing** `boolean`

**open** `boolean`

The preferences panel is open.

**allows(category)** `boolean`

`"necessary"` is always allowed.

**acceptAll() / rejectAll()** `void`

**save(choice)** `void`

`{ analytics, marketing }`.

**reset()** `void`

Withdraw: forget the decision and show the banner again.

**openSettings() / closeSettings()** `void`

**store** `ConsentStore`

`useConsent()` throws without a consent provider above.

### ConsentBanner

```tsx theme={null}
<ConsentBanner lang="sv" privacyPolicyUrl="/integritetspolicy" />   // the default accessible dialog
<ConsentBanner>{(state) => state.visible && <aside>…</aside>}</ConsentBanner>   // headless
```

With no children it renders the kit's styled, accessible dialog; with a render function it renders only what you return. A banner you place replaces the provider's default one.

**children** `(state: ConsentBannerState) =\> ReactNode`

`state` is the consent snapshot plus `visible`, `labels`, `draft`, `setDraft(partial)`, `acceptAll`, `rejectAll`, `save` (saves the draft), `reset`, `openSettings`, `closeSettings`.

**lang** `string | null`

**labels** `Partial\<ConsentLabels\> | null`

**privacyPolicyUrl** `string | null`

**className** `string`

**unstyled** `boolean`

Leave out the stylesheet.

**showWhenDecided** `boolean`

Keep it visible after a decision.

`visible` is true while undecided, while the preferences panel is open, or with `showWhenDecided`. The banner renders nothing before hydration unless the provider got `initialState`.

### ConsentSettingsButton

```tsx theme={null}
<ConsentSettingsButton className="link" />
<ConsentSettingsButton>Ändra cookieval</ConsentSettingsButton>
```

A real `<button type="button">` that reopens the banner's preferences, for a footer. Labelled "Cookie settings" in the provider's `lang` when given no children. Takes every `<button>` attribute plus `lang`.

### ConsentGate

```tsx theme={null}
<ConsentGate category="marketing" fallback={<p>Allow marketing cookies to see the video.</p>}>
  <iframe src="https://www.youtube.com/embed/…" />
</ConsentGate>
```

Renders `children` only once `category` is allowed, `fallback` until then.

### AnalyticsProvider

```tsx theme={null}
<AnalyticsProvider destinations={[tiktok]}>{children}</AnalyticsProvider>
```

The analytics hub, gated on the consent store above. `<ShopkitProvider>` mounts one by default; an explicit one inside it joins that hub (its `destinations` are added) instead of loading the pixels twice.

**destinations** `AnalyticsDestination[]`

Destinations of your own, on top of (or with `auto: false`, instead of) the shop's.

**auto** `boolean` (default: true)

Load the merchant's GA4, GTM and Meta pixel from `shop.tracking`.

**requireConsent** `boolean` (default: true)

`false` runs analytics ungated, and makes the hosted checkout track ungated too. Only for a storefront that owes its shoppers no consent.

**loadBeforeConsent** `boolean` (default: false)

Load GTM or gtag.js before the shopper decides, under a Consent Mode default of everything denied. A GTM container loaded this way runs all of its tags.

**currency** `string`

The currency for events that carry none. Falls back to the cart's.

**storeId** `string | number | null`

The shop's numeric store id, for the purchase dedup key and Meta's `eventID`. Learned from the cart when omitted.

**bufferSize** `number` (default: 50)

Events remembered for destinations not ready yet. Minimum 1.

**debug** `boolean`

Log every dispatch.

### useAnalytics / useOptionalAnalytics

```ts theme={null}
const analytics = useAnalytics()           // throws without a hub
const maybe = useOptionalAnalytics()       // or null
analytics.track(viewItemListEvent(items, "New in"))
```

The `Analytics` hub. See [Utilities](https://quickbutik.dev/kit/reference/utilities.md#consent-and-analytics) for its methods and the event builders.

### useTrackPurchase

```ts theme={null}
const { tracked, error } = useTrackPurchase({ orderNumber, sessionId?, enabled?, affiliation? })
```

Reports the `purchase` for an order number you already have, from the checkout session's lines and total. Deduplicated per order across page loads, so it never double-counts beside `useOrderConfirmation`. Pass `sessionId` explicitly when `useOrderConfirmation` runs on the same page, because its completed poll forgets the remembered session. `tracked` is true once reported, here or on an earlier visit.

## SEO

See [SEO](https://quickbutik.dev/kit/concepts/seo.md).

### SeoProvider

```tsx theme={null}
<SeoProvider baseUrl="https://myshop.com" shop={shop} currency="SEK" productPath="/products/{slug}" organization>
  {children}
</SeoProvider>
```

Takes every `SeoDefaults` field: `baseUrl`, `siteName`, `titleTemplate`, `locale`, `defaultImage`, `twitterSite`, `twitterCreator`, `currency`, `productPath`, `categoryPath`, `shop`, `organization`. `useSeoDefaults()` reads them back.

### SEO

```tsx theme={null}
<SEO />                                         // inside <ProductProvider>
<SEO product={product} url={`/products/${product.slug}`} />
<SEO category={category} url="/categories/shirts" />
<SEO title="Tack för din order" noIndex noFollow />
```

Renders the title, meta tags, canonical, OpenGraph, Twitter card and JSON-LD. Takes every `SeoInput` and `SeoDefaults` field, plus `skipTitle` and `skipJsonLd`. React 19 hoists the tags into `<head>`; on React 18 use `useSeo()` with your framework's head.

### useSeo

```ts theme={null}
useSeo(input?: SeoInput & SeoDefaults): SeoTags
```

### JsonLd

```tsx theme={null}
<JsonLd data={tags.jsonLd} />
```

Renders `<script type="application/ld+json">` for one node or many. For Next.js `generateMetadata` pages, whose metadata has no JSON-LD slot.

## CartStore

`CartStore` and its `CartSnapshot` type are exported from this entry. See [Cart](https://quickbutik.dev/kit/reference/cart.md). So are `ConsentStore`, `Analytics` and the consent and analytics types (`ConsentState`, `ConsentSnapshot`, `ConsentCategory`, `ConsentChoice`, `ConsentLabels`, `AnalyticsDestination`, `CommerceEvent`, `CommerceItem`, `PurchaseEvent`), so a React app needs no second import.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.