createFormCartActions
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
function createFormCartActions(opts: { typed: TypedCartActions }): FormCartActions;Parameters
| Name | Type | Description |
|---|---|---|
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>Related
AuthBridge CartIdStorage CreateTypedCartActionsOpts FormCartActions HttpOnlyCookieStorageOpts NextEventBridge TypedCartActions NextEventBridgeHandlers
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
CreateTypedCartActionsOpts
Construction options for . Wires together the kernel, storage, and requestcontext factory that the typed action surface needs; optional authBridge and messageLo