createFormCartActions

cart · /next·function

Wraps a surface in zero-JS FormData adapters. Each wrapper parses the form, mints a server-side idempotency key, and forwards the typed call — so the same action works whether the page is progressively enhanced (predictive client queue) or running with JS disabled (native <form action={...}>).

Validation lives here, not in : parsing failures short-circuit with ok: false before any kernel call, so an invalid form post never touches the cart provider.

Signature

@nordcom/commerce-cart

Parameters

NameTypeDescription
opts{ typed: TypedCartActions }

Returns

A surface ready for <form action> bindings.

Example

const formActions = createFormCartActions({ typed });

// Wire into a Server Component form — works with or without client JS:
<form action={formActions.addLineAction}>
    <input name="variantId" value="gid://shopify/ProductVariant/123" />
    <input name="quantity" value="1" />
    <button type="submit">Add to cart</button>
</form>

AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers

On this page