Packages narrative
packages / cart / react
cart / react
Functions
| Name | Description |
|---|---|
cachePredictor | Build a line predictor that looks merchandise up via a host-supplied KV getter (e.g., a product cache keyed by variant id). The returned partial merchandise is merged onto a minimal placeholder so the cache only needs to provide the fields it actually knows. |
quantitySumPredictor | Build a cart-level predictor that recomputes |
snapshotPredictor | Build a line predictor that derives a predicted cart line directly from the inline |
subtotalPredictor | Build a cart-level predictor that recomputes |
useCart | Composite hook stitching every slice into the shape historically returned by the storefront's monolithic |
useCartActions | Read the capability-typed actions object built by the provider. Throws when used outside |
useCartCapabilities | Read the cart capabilities surfaced by the kernel snapshot. Throws when called outside a |
useCartCost | Read the optimistic-aware cost slice from the nearest cart provider. |
useCartCount | Read the optimistic-aware total quantity from the nearest cart provider. |
useCartDispatch | Read the low-level dispatch function that bypasses the capability-typed action surface — useful for custom mutations carried via |
useCartEvents | Subscribe to a single cart event type for the lifetime of the calling component. Re-subscribes whenever |
useCartLines | Read the optimistic-aware lines slice from the nearest cart provider. |
useCartMeta | Read the cart meta slice (discount codes, gift cards, buyer identity, note, attributes, checkout URL) from the nearest provider. |
useCartPending | Read pending mutations from the provider — either the whole queue or the single entry currently targeting a specific line id. |
useCartStatus | Read the cart status (idle/mutating/error) and seeding flag. |
useMaybeCart | Variant of |
Components
| Name | Description |
|---|---|
CartDevtools | Development-only overlay that renders a toggleable JSON dump of cart provider state. Returns |
CartForm | Renders a |
CartHydrator | Server-renderable entry point that seeds the client-side cart hydration marker. Delegates to a client component that renders a hidden element carrying the initial cart id and shop id, so the client layer can bootstrap without an extra network round-trip. |
CartProvider | Root context provider for the Nordcom cart. Manages the optimistic mutation queue, projects the cart for all slice hooks, synchronizes state with cross-tab broadcasts, and optionally keeps buyer identity in sync via a client auth bridge. |
Interfaces
| Name | Description |
|---|---|
CartFormProps | Props for |
CartProviderProps | Props for |
Types
| Name | Description |
|---|---|
AppCartConfig | Compile-time pairing of a capability matrix and an extension shape used to thread consistent type parameters through |
BaseCartActions | Minimum mutation surface every cart adapter must implement: add, update, and remove cart lines, plus |
BuyerIdentityActions | Buyer-identity sync method added to |
CartActions | Full action surface for a cart, assembled from |
CartAttributeActions | Cart-attribute mutation method added to |
CartPredictor | A function that projects the entire cart after a pending mutation has been applied to the lines. Use it to recompute cart-level aggregates — such as total quantity or subtotal — that depend on the mutated line set. |
ClientAuthBridge | Minimal React hook contract that exposes buyer identity to |
DiscountActions | Discount-code mutation methods added to |
GiftCardActions | Gift-card mutation methods added to |
KernelSnapshot | Static capabilities snapshot produced by the cart adapter and passed from the server to the client via |
LinePredictor | A function that optimistically projects a single cart line given a pending mutation. Called once per |
NoteActions | Cart-note mutation method added to |
PendingMutation | A single mutation in flight through the optimistic queue — from when it is first predicted through server confirmation or failure. |
PredictorCtx | Contextual snapshot passed to every |
TypedCartActions
Stronglytyped serveraction surface built by . Each method accepts a serializable plainobject args bag (no FormData) so client components can invoke actions thro
AppCartConfig
Compiletime pairing of a capability matrix and an extension shape used to thread consistent type parameters through and its associated hooks. Define one per app