Packages narrative
packages / cart / react

cart / react

Functions

NameDescription
cachePredictorBuild 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.
quantitySumPredictorBuild a cart-level predictor that recomputes
snapshotPredictorBuild a line predictor that derives a predicted cart line directly from the inline
subtotalPredictorBuild a cart-level predictor that recomputes
useCartComposite hook stitching every slice into the shape historically returned by the storefront's monolithic
useCartActionsRead the capability-typed actions object built by the provider. Throws when used outside
useCartCapabilitiesRead the cart capabilities surfaced by the kernel snapshot. Throws when called outside a
useCartCostRead the optimistic-aware cost slice from the nearest cart provider.
useCartCountRead the optimistic-aware total quantity from the nearest cart provider.
useCartDispatchRead the low-level dispatch function that bypasses the capability-typed action surface — useful for custom mutations carried via
useCartEventsSubscribe to a single cart event type for the lifetime of the calling component. Re-subscribes whenever
useCartLinesRead the optimistic-aware lines slice from the nearest cart provider.
useCartMetaRead the cart meta slice (discount codes, gift cards, buyer identity, note, attributes, checkout URL) from the nearest provider.
useCartPendingRead pending mutations from the provider — either the whole queue or the single entry currently targeting a specific line id.
useCartStatusRead the cart status (idle/mutating/error) and seeding flag.
useMaybeCartVariant of

Components

NameDescription
CartDevtoolsDevelopment-only overlay that renders a toggleable JSON dump of cart provider state. Returns
CartFormRenders a
CartHydratorServer-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.
CartProviderRoot 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

NameDescription
CartFormPropsProps for
CartProviderPropsProps for

Types

NameDescription
AppCartConfigCompile-time pairing of a capability matrix and an extension shape used to thread consistent type parameters through
BaseCartActionsMinimum mutation surface every cart adapter must implement: add, update, and remove cart lines, plus
BuyerIdentityActionsBuyer-identity sync method added to
CartActionsFull action surface for a cart, assembled from
CartAttributeActionsCart-attribute mutation method added to
CartPredictorA 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.
ClientAuthBridgeMinimal React hook contract that exposes buyer identity to
DiscountActionsDiscount-code mutation methods added to
GiftCardActionsGift-card mutation methods added to
KernelSnapshotStatic capabilities snapshot produced by the cart adapter and passed from the server to the client via
LinePredictorA function that optimistically projects a single cart line given a pending mutation. Called once per
NoteActionsCart-note mutation method added to
PendingMutationA single mutation in flight through the optimistic queue — from when it is first predicted through server confirmation or failure.
PredictorCtxContextual snapshot passed to every

On this page