createCartEnsurer
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
function createCartEnsurer(opts: { kernel: CartKernel<TExt, TShop>; reader: (ctx: AdapterCtx<TShop>) => Promise<Cart<TExt>>; storage: CartIdStorage }): (ctx: AdapterCtx<TShop>) => Promise<Cart<TExt>>;Parameters
| Name | Type | Description |
|---|---|---|
opts | { kernel: CartKernel<TExt, TShop>; reader: (ctx: AdapterCtx<TShop>) => Promise<Cart<TExt>>; storage: CartIdStorage } |
Returns
Async ensurer that always resolves to a .
Related
AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers
CartIdStorage
Pluggable persistence contract for the active cart's identifier. cartnext ships as the default Next.js implementation; hosts on other transports (Redis, signed
createCartReader
Builds an RSCsafe reader that resolves the active cart for the current request. The reader is wrapped in react.cache so that multiple Server Components renderin