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
latest, a semver range, a Git URL, or a workspace build in a released storefront.
Replace configuration
Remove the 1.x browser configuration: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, ordeliveryfor fulfillment. Set table and room identifiers throughcart.setTable()andcart.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
amountorpercentagetocart.updateGratuity(). - Send a full supported country name such as
United States, notUS. - Send table numbers as numeric strings such as
"12", not"T-12"or"Patio 3". - Treat
marketplaceIdas 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
- Configure the explicit public API origin for the correct environment.
- Provide a
StorefrontSessionStorefor{ locationId, cartId, accessToken, revision }, scoped by canonical API environment, merchant, and location. - 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. - Let cart methods attach
X-Cart-Token,If-Match, andIdempotency-Key. OnCART_CONFLICT, refresh and ask the customer to retry; never silently replay intent. - Store the merchant-bound customer JWT in versioned, tab-scoped browser storage or
expo-secure-store, and clear it on logout. - Replace legacy payment calls with
checkout.createPaymentIntent()and boundedcheckout.getOrderResult()polling; stop reading the removedstripeAccountIdresponse field. - Capture a receipt capability from the URL fragment, remove the fragment immediately, and scope storage by environment, merchant, and receipt ID.
- Register each exact deployed browser origin with Crave. Native apps normally need no CORS registration; Expo web does.
- 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_CONFLICTand are not automatically replayed. - Only
completedis 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.
Slack Community
Ask questions and get help from the Crave team and community.
Email Support
Reach out to hello@craveup.com for direct support.