Skip to main content
Storefront SDK 2.0.0 is a major version. It replaces the published 1.x browser API-key client with the direct public /api/v1/storefront contract. Treat the upgrade as an application migration: use a branch, update all callers together, and verify a sandbox order before production. Published 1.x artifacts remain a durable npm history. Do not unpublish them or silently replace their contents. They may be deprecated after 2.0.0 is verified, but 2.x does not include an API-key shim, a dual transport, or duplicate names for the same operation. Use the canonical cart.applyDiscount(), cart.removeDiscount(), and loyalty.ledger() methods.

Install the exact major

Commit the updated lockfile. Do not use latest, a semver range, a Git URL, or a workspace build in a released storefront.

Replace configuration

Remove the 1.x browser configuration:
Create a 2.x browser client with public configuration and caller-owned stores:
Create a separate server client with only baseUrl; use it for anonymous published reads. Remove browser/mobile API keys, mint endpoints, BFF proxies added only for the old SDK, and hand-built authorization headers.

Update methods, arguments, and types

Only SCAN, CART_VIEW, and CHECKOUT_VIEW remain valid client analytics events. StorefrontClientStateError provides a typed local preflight failure, including CUSTOMER_AUTH_REQUIRED, before a request is sent without required customer authentication.

Update response handling

Do not rely on structural casts to bridge these response changes. Remove wrapper access such as result.cart, replace success-only branches with the returned authoritative cart, and recompile every caller against 2.0.0. Product fixtures and adapters must now provide the required Product.locationId. OrderTimesResponse exposes labeled orderDays; replace the legacy regular-day { from, to } interval branch and render only the days and intervals returned by the API.

Update request validation

  • Use only takeout, table_side, room_service, or delivery for fulfillment. Set table and room identifiers through cart.setTable() and cart.setRoom() rather than a generic cart patch.
  • Use cart.updateOrderTime() for scheduling. cart.update() accepts fulfillment and/or a note, not order-date or order-time fields.
  • Send exactly one of amount or percentage to cart.updateGratuity().
  • Send a full supported country name such as United States, not US.
  • Send table numbers as numeric strings such as "12", not "T-12" or "Patio 3".
  • Treat marketplaceId as optional source attribution such as "web" or "mobile"; it is not a location ID.
  • For a signed-in shopper who still has a guest-capability cart, use the named { includeCustomerContext: true } request option only when customer-aware discount validation or Stripe customer association is needed. Omit it for a guest; claimed carts use the customer JWT automatically.

Required migration

  1. Configure the explicit public API origin for the correct environment.
  2. Provide a StorefrontSessionStore for { locationId, cartId, accessToken, revision }, scoped by canonical API environment, merchant, and location.
  3. Create carts through orderingSessions.start(). Let the SDK persist the returned capability and authoritative revision; do not copy the token into application state or UI props.
  4. Let cart methods attach X-Cart-Token, If-Match, and Idempotency-Key. On CART_CONFLICT, refresh and ask the customer to retry; never silently replay intent.
  5. Store the merchant-bound customer JWT in versioned, tab-scoped browser storage or expo-secure-store, and clear it on logout.
  6. Replace legacy payment calls with checkout.createPaymentIntent() and bounded checkout.getOrderResult() polling; stop reading the removed stripeAccountId response field.
  7. Capture a receipt capability from the URL fragment, remove the fragment immediately, and scope storage by environment, merchant, and receipt ID.
  8. Register each exact deployed browser origin with Crave. Native apps normally need no CORS registration; Expo web does.
  9. Delete the obsolete 1.x client, API-key configuration, wrapper types, adapters, tests, and documentation in the same application change.

Verification checklist

  • Public bundles contain no private Crave or payment-provider secrets.
  • Published merchant, location, menu, product, distance, order-time, and gratuity requests carry no customer JWT.
  • Wrong, expired, cross-location, and cross-merchant capabilities are denied.
  • Stale revisions return CART_CONFLICT and are not automatically replayed.
  • Only completed is treated as checkout success.
  • CORS is restricted to the exact deployed storefront origins.
  • A clean install, typecheck, production web build or Expo export, and sandbox vertical slice use the exact registry artifact.
If a production 1.x storefront cannot move atomically, keep its pinned 1.x artifact and deployed API path unchanged while a separate 2.0.0 release candidate is verified. Do not make one bundle switch between the two contracts at runtime.

Slack Community

Ask questions and get help from the Crave team and community.

Email Support

Reach out to hello@craveup.com for direct support.