Basket Management Differences with PWA Kit

PWA Kit and Storefront Next rely on the Shopper Baskets API, but they differ in where basket state is managed and how it is hydrated in the app lifecycle. PWA Kit commonly uses hook-driven basket reads and mutations in components, while Storefront Next uses middleware, request context, and route loaders and actions to manage basket state with a server-first model.

AspectPWA KitStorefront Next
Basket API baselineShopper Baskets V1 is available and remains the default for many existing importsBasket flows are implemented with shopperBasketsV2 patterns in loaders/actions
Primary integration model@salesforce/commerce-sdk-react hooks in componentsMiddleware + request context + route loaders/actions
Basket state locationReact Query cache and component hook stateCookie snapshot on the server plus optional client hydration in provider state
Hydration strategyData fetched when basket hooks run in UILazy by default: hydrate full basket only when required
PhasePWA KitStorefront Next
Initial requestBasket data is typically fetched through basket hooks used by rendered componentsMiddleware reads basket cookie snapshot and attaches it to request context
Basket creation/accessHook and mutation flows resolve or create basket during shopper actionsensureBasketId and server helpers manage basket identity in loaders/actions
Client updatesMutations update React Query caches and UI stateActions update server resource context; client can sync through provider updater hooks
Post-checkout cleanupApp-specific hook/mutation flows clear basketdestroyBasket() and provider reset hooks clear server/client basket state

When moving basket functionality from PWA Kit to Storefront Next:

  1. Move basket reads out of components and into route loaders when possible.
  2. Move basket mutations to route actions and update request-scoped basket context.
  3. Treat basket cookie snapshot data as the default source for lightweight UI state (for example, cart badge counts).
  4. Use lazy hydration for full basket payloads only in routes or components that require full basket detail.
  5. Keep basket API usage consistent across the codebase to avoid stale or mismatched basket state behavior.
  • Both storefronts use SCAPI basket endpoints for cart operations.
  • Both support guest and authenticated shopper basket flows.
  • Both can preserve basket continuity across shopper navigation.