createCartEnsurer

cart · /next·function

Builds an "ensure a cart exists" helper for server actions and RSC entry points that need a non-null cart to operate on. Delegates to the supplied reader for the existing-cart path so cache dedup is preserved, then falls back to kernel.create({}) + storage.set(cart.id) when nothing is stored.

Signature

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

Parameters

NameTypeDescription
opts{ kernel: CartKernel<TExt, TShop>; reader: (ctx: AdapterCtx<TShop>) => Promise<Cart<TExt>>; storage: CartIdStorage }

Returns

Async ensurer that always resolves to a .

AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers

Sourcereader.ts:71Edit the JSDoc directly

On this page