createTypedCartActions
Builds the typed, JSON-arg server-action surface for cart-next hosts.
Each returned method threads the supplied idempotencyKey into
via resolveContext({ idempotencyKey }) and routes the
call through the kernel — so middleware (logger, tracing, idempotency,
retry, analytics) runs on every action just as it would for a direct
kernel.mutate call.
Error mapping is centralised here: anything thrown becomes a typed
CartActionResult with a localized message, instead of bubbling raw
provider exceptions across the server-action boundary.
Signature
function createTypedCartActions(opts: CreateTypedCartActionsOpts<TExt, TShop>): TypedCartActions<TExt>;Parameters
| Name | Type | Description |
|---|---|---|
opts | CreateTypedCartActionsOpts<TExt, TShop> |
Returns
A surface ready to bind as "use server"
re-exports.
Example
const actions = createTypedCartActions({
kernel,
storage: httpOnlyCookieStorage(),
resolveContext: async ({ idempotencyKey } = {}) => ({ shop, locale, idempotencyKey }),
});
const result = await actions.addLine({
variantId: 'gid://shopify/ProductVariant/123',
quantity: 1,
idempotencyKey: crypto.randomUUID(),
});Related
AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers
CreateTypedCartActionsOpts
Construction options for . Wires together the kernel, storage, and requestcontext factory that the typed action surface needs; optional authBridge and messageLo
FormCartActions
Set of FormDatadriven server actions returned by . Each method parses and validates a FormData payload before delegating to the typed action surface, enabling n