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
| Import | Use it in | Gives you |
|---|---|---|
@usestorekit/sdk | Any JS runtime (server) | createStorefrontClient() — the core client |
@usestorekit/sdk/next | Next.js server (RSC, Actions, route handlers) | initStorekit() — the Next.js adapter |
@usestorekit/sdk/react | Browser (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 zodEverything 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); // typedSee 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):
Catalog
products · categories · search · store
Cart & checkout
cart · checkout · coupons
Customers
auth · customer · orders · addresses
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
formatMoney(amount, currency?, locale?)— locale-pinned currency formatting (SSR-safe).- Error guards:
isStorefrontError,isRateLimited,isUnauthorized,isNotFound. - Session stores:
memorySession,staticSession,cookieSession.