Shopify Hydrogen and Oxygen headless cart with @shopify/hydrogen-react

domain: shopify.dev · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Install @shopify/hydrogen-react and initialize ShopifyProvider with your storeDomain, storefrontApiVersion, and storefrontToken at the app root.
  2. Use the CartProvider component to wrap your app; it manages cart state via React context and handles cartCreate, cartLinesAdd, cartLinesRemove, and related mutations automatically.
  3. Access cart state and actions via the useCart hook: cartId, lines, totalQuantity, linesAdd, linesRemove, discountCodesUpdate, and others.
  4. For Hydrogen (full-stack Remix framework), use server-side cart actions via the cart API helpers in Hydrogen rather than client-side CartProvider to support progressive enhancement.
  5. Configure environment variables SHOPIFY_STORE_DOMAIN, SHOPIFY_STOREFRONT_ACCESS_TOKEN, and SHOPIFY_STOREFRONT_API_VERSION in Oxygen (or .env locally).
  6. Consult the current @shopify/hydrogen-react changelog to confirm which Storefront API version is required for each hook and component.

Known gotchas

Related routes

Implement a Hydrogen cart using createCartHandler and wire it to cart actions in a Remix app
shopify.dev · 6 steps · unrated
Deploy a Shopify Hydrogen storefront to Oxygen and configure route-level caching with stale-while-revalidate headers
shopify.dev · 6 steps · unrated
Deploy a Shopify Hydrogen app to Oxygen and configure environment variables and secrets
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 200+ more routes

One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp