StoreKitdocs
SDK

Overview

The @usestorekit/sdk surfaces — core client, Next.js adapter, and browser hooks.

@usestorekit/sdk is the type-safe client for the Storefront API. It exposes three entry points; pick the ones that match where your code runs.

Entry points

ImportUse it inGives you
@usestorekit/sdkAny JS runtime (server)createStorefrontClient() — the core client
@usestorekit/sdk/nextNext.js server (RSC, Actions, route handlers)initStorekit() — the Next.js adapter
@usestorekit/sdk/reactBrowser (Client Components)createStorekitClient() + hooks

The usual Next.js setup uses two surfaces

You use @usestorekit/sdk/next on the server (holds your store key, reads data, runs the proxy) and @usestorekit/sdk/react in the browser (hooks that call the proxy). See the quickstart.

Install

npm install @usestorekit/sdk zod

Everything returns a result

Every method returns Promise<Result<T>>{ data, error } — and never throws by default:

const { data, error } = await client.products.list({ limit: 12 });
if (error) return handle(error);
use(data); // typed

See Errors & results.

Resources at a glance

All three clients expose the same resource namespaces (the Next.js and browser clients add cookie-backed cart/auth on top):

Per-request options

Every method takes an optional final options argument:

await storekit.products.list(
  { limit: 12 },
  {
    revalidate: 600,          // Next.js ISR seconds
    tags: ["storekit:products"], // cache tags for revalidateTag()
    cache: "no-store",        // fetch cache mode
    signal: controller.signal, // AbortSignal
    headers: { "X-Trace": "1" },
    outletId: "out_123",      // override the outlet for this call
  },
);

Helpers

On this page