Headless cart
Two carts on the Shopify Storefront API, built two ways: one lives in the browser and only calls Shopify at checkout, the other asks Shopify at every step.
- Year
- 2026
- Type
- Technique
- Stack
- Storefront API, JavaScript
- Status
- Live in two shops

The photographs on this page are illustrations made for this site, not screenshots of the project.
What it is
A headless shop has to bring its own cart. Shopify offers a cart through the Storefront API, but when and how often you talk to it is a design decision. In two shops I built at The Creativity Lab, that decision went two different ways.

A cart that lives in the browser
In the first shop the cart is local. Adding a product makes no network request, so the drawer opens at once and never waits on anything. Only when the customer chooses to check out does the site build cart lines, call Shopify once to create a cart, and redirect to the checkout URL that comes back.
The price of that speed is that the site does its own arithmetic. The shop has a tiered discount, so the site asks Shopify to price a throwaway cart and shows that result. Otherwise the drawer and the checkout could show different totals.

A cart that asks Shopify
The second shop keeps the cart at Shopify. Adding, changing and removing lines and applying a discount code are all mutations, and the interface waits for the answer before it updates. It is slower by one round trip, and it never shows a state Shopify does not agree with.
- Checkout creates a fresh cart on every attempt and never reuses a stored cart ID, so a retry can not double the quantities.
- Delivery details the customer typed are passed along so the checkout opens filled in. They are a convenience, never a condition: if Shopify rejects one field, the next attempt drops only that part, and the lines are never touched.
- Checkout refuses to run in any fallback state. A shop that is showing a local copy of the catalogue can be browsed, but it can not sell.

What to take from it
Neither is better in general. A local cart suits a small catalogue where stock rarely runs out between adding and paying. A server cart suits drops and limited stock, where a stale cart is worse than a short wait. In both, Shopify's checkout has the last word: its documentation says the costs on a cart are estimates that can change at checkout.
One thing applies to both. Shopify's cart ID contains a secret key and its documentation says to treat it like a password, so it does not belong in a shareable link.
Read further
More work.
Let’s talk
Curious about an experiment, or want to compare notes? I'd like to hear from you.
Need a website or a designer? That's The Creativity Lab. Visit the studio

