Skip to main content
The SDK uses Shopify’s hosted web checkout. Each cart exposes a checkoutUrl; the SDK tracks a checkout session over that cart so screens can create, restore, open, poll and report the outcome.

Quick start

Create a fresh checkout

create builds a new cart for the given line items, persists its id, and publishes the session. Use it for “Buy now” flows; for the cart the shopper already built, open() (or restore()) reuses it.

Hook API

useCheckout restores the stored cart on mount, so returning to the checkout screen after an app restart shows the same session without a manual step.

Session shape

CheckoutSession is a view over the cart — Storefront removed the old checkout* API (verified against 2026-07), so there is no separate checkout object:
toCheckoutSession(cart) is exported (pure) if you already hold a cart node.

Completion, cancellation and expiry

Storefront does not expose checkout status: there is no expiresAt, no completedAt and no cancel mutation. The SDK does not invent them.
After a completed order, the stored cart id is stale; the next cart read self-heals. You can also clear it explicitly with useCart().clearCart().
The reference engine polls every 3s, matches success/cancel URL patterns, listens to AppState/Linking and persists a recovery record. All of that is app-specific navigation policy. The SDK exposes the primitives (refresh, markCompleted, markCancelled) and leaves timing to your app; Storefront already persists the cart, so no recovery engine is needed.

Legacy: getCheckoutUrl

Still works and returns the restored session’s URL when one exists, otherwise falls back to cart.getCheckoutUrl(). Prefer open(), which keeps the session state in sync. The URL is also available from useCart() as cart.checkoutUrl once the cart is loaded.

Flow

  1. Build the cart with addLines / updateBuyerIdentity.
  2. const url = await open() (or create(lines) for a new cart).
  3. Open the URL in an in-app browser or web view.
  4. Shopify handles address, shipping and payment.
  5. On return: refresh() on foreground, plus markCompleted() / markCancelled() from your deep-link handler.
  6. The order appears in useOrders() / useOrderTracking().