---
title: Cart
description: The cart system - Hydrogen cart handlers, optimistic store, server actions, and Shopify integration.
type: guide
---

# Cart



<CartBrowser />

The storefront ships with a shared Shopify cart across product pages, the cart overlay, the full cart page, checkout, and the optional shopping assistant. Shoppers see changes immediately while Shopify confirms prices, discounts, and availability.

No additional setup is required for the standard cart. The cart ID is stored in a `cart` cookie for 14 days. After that cookie expires, the shopper starts a new cart.

## Shopper experience

Shoppers can add products, change quantities, remove lines, apply discount codes, and proceed to checkout. The cart overlay is available throughout the storefront, and `/cart` provides the full cart with product recommendations.

Updates are optimistic: quantities and badges change immediately, then reconcile with Shopify. If Shopify rejects a change, the cart returns to its confirmed state and shows the relevant error. Checkout remains unavailable while totals are still being confirmed.

The cart displays confirmed discounts and sale pricing. Shopify bundles remain grouped so shoppers can understand which products belong together. Quantity and remove controls follow Shopify's rules for each line, so some bundle lines may not be editable individually.

When customer authentication is enabled, sign-in can attach the existing browser cart to the customer. Checkout can then use the customer's saved details. See [Authentication](/docs/anatomy/authentication).

The optional shopping assistant uses the same cart, so changes made in chat appear in the cart overlay and on `/cart`.

If `NEXT_PUBLIC_SHOPIFY_STOREFRONT_ID` is set, server-side cart activity is attributed to the corresponding Headless storefront. See [Environment Variables](/docs/reference/env-vars).

## Important limits

* The cart lasts only as long as its 14-day cookie.
* Shopify remains authoritative for inventory, prices, discounts, and line-editing rules.
* Cart updates can fail because of availability, quantity, discount, or checkout restrictions.
* Gift cards and bundles can carry information that ordinary product lines do not; preserve that data when extending cart behavior.

## What’s next

You can adjust the cart lifetime, expose order-level attributes, support personalized products, or add custom bundle purchase flows. Keep the cookie lifetime aligned with Shopify's cart handling, preserve all line attributes needed at checkout, and continue treating Shopify's confirmed cart as the source of truth.


---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)