createCartReader

cart · /next·function

Builds an RSC-safe reader that resolves the active cart for the current request. The reader is wrapped in react.cache so that multiple Server Components rendering in one request share a single adapter call.

When the stored id no longer resolves on the provider — either null from the adapter or a thrown — the reader clears the storage so the next request creates a fresh cart instead of resurrecting a dangling id.

Signature

@nordcom/commerce-cart
function createCartReader(opts: { kernel: CartKernel<TExt, TShop>; storage: CartIdStorage }): (ctx: AdapterCtx<TShop>) => Promise<Cart<TExt>>;

Parameters

NameTypeDescription
opts{ kernel: CartKernel<TExt, TShop>; storage: CartIdStorage }

Returns

Async reader returning the resolved or null.

AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers

Sourcereader.ts:34Edit the JSDoc directly

On this page