ProductHow it worksDocsBlogPricingSign inGet Framer Plugin
← Blog

Shopify Cart in Framer: Persistence, Drawers and Handoff

A Shopify cart on a Framer site should be created inside Shopify through the Storefront API, with the returned cart ID stored in the browser so it survives navigation. Framer renders the interface — the product grid, the drawer, the quantity steppers — while Shopify owns the line items, the prices and the inventory check. A cart that exists only in Framer's component state is not a Shopify cart at all: it disappears the moment someone clicks through to another page, and it hands Shopify nothing to recover later.

That distinction is the single most common reason a beautiful Framer storefront loses orders. Everything below assumes the design is already good. The question is where the cart actually lives.

What a Shopify cart actually is

A Shopify cart is a server-side object, not a list in your frontend's memory. It has an ID, it holds line items against real variant IDs, and Shopify prices it. Once you accept that, the behaviour stops being mysterious: Shopify states that unused and abandoned carts automatically expire within 30 days of creation, that the cart is deleted once the customer completes their checkout, and that a shop can create an unlimited number of carts.

Unlimited carts matters more than it sounds. It means you never need to be clever about recycling a cart ID. If the stored one fails, create a new one and move on.

Why does the cart break on a Framer site?

Because a Framer page is a React tree, and a React tree unmounts. If your add-to-cart handler pushes an object into a useState array, that array has exactly the lifespan of the page. Navigate to another product, and the cart is empty. Refresh, and it is empty. Open the site tomorrow on the same device, and it is empty.

Worse, a purely local cart has no idea what Shopify thinks. It will happily let someone add a variant that sold out an hour ago, which is precisely the failure pattern behind the recurring "add to cart not working, product showing out of stock on live site but in stock in the editor" reports in the Framer and Shopify communities. The frontend is confidently wrong because it never asked.

Which cart implementation should a Framer storefront use?

There are four realistic options, and they are not close once you score them on anything other than setup time.

Implementation Survives page navigation Survives a browser session Inventory checked on add Discount codes Abandoned checkout recorded Analytics events you control
Local Framer component state No No No No No — nothing reaches Shopify Full, but on fictional data
Buy Button iframe Per embed only No Yes, inside the iframe Limited, at checkout Yes (Buy Button channel) Almost none — cross-origin
Cart permalink Nothing to survive No At checkout only Yes, via ?discount= Yes, once email is given Only up to the click
Storefront API cart Yes Yes, via stored cart ID Yes, at add time Yes, on the cart Yes, once email is given Full, on real line items

The permalink route is genuinely useful for a single campaign link — Shopify's format is /cart/{variant_id}:{quantity} and it supports up to 25 line item properties on the first product, with discount codes passed in the URL. It is not a cart. It is a one-way door to checkout, with no state before the click and no selling-plan support.

The Buy Button is the opposite trade: it carries a real cart but seals it inside an iframe you cannot style or instrument. We covered why that ceiling arrives fast in the Shopify Buy Button's limits on Framer.

One option is missing from that table on purpose. The Ajax Cart API — the /cart/add.js endpoints that power a classic Shopify Ajax cart — is scoped to the storefront's own domain. A Framer site served from your own domain is a different origin, so that Shopify cart API is not available to it. For an off-domain frontend, the Storefront API is the cart API.

How do you keep a Shopify cart from disappearing between pages?

Create the cart in Shopify, persist its ID, and re-read it on load. That is the entire mechanism, and it is three steps:

  1. On first add to cart, call cartCreate and keep the returned cart ID.
  2. Store that ID in the browser so the next page can find it.
  3. On every page load, query Shopify with the stored ID and render whatever Shopify returns — never a local copy.

One detail trips up almost every first implementation. The cart ID is not a plain token: Shopify documents it as <token>?key=<secret>, and the full ID is required for every cart operation. Shopify's guidance on that secret is blunt:

Never expose the secret part of the ID in shareable links, public pages, or any client-side code. — Shopify, Create and update a cart with the Storefront API

Read literally, that rules out putting the full ID into a "share my cart" URL or printing it into server-rendered HTML. It does not mean you cannot hold a cart for a returning buyer — it means the place you hold it has to be scoped to that one browser, and anything resembling a public or shareable surface is out. If you need a link someone can forward, build it from a permalink, not from the cart ID.

Batching helps too: Shopify allows up to 250 lines in a single cartLinesAdd request, so a "reorder everything" button is one call, not fifty.

Does a Framer cart drawer work like a Shopify one?

Functionally yes, structurally no. In a Liquid theme, the drawer is a theme setting — you pick drawer, page or popup and the theme does the rest. In Framer there is no such setting, so the drawer is just an overlay component you build, positioned over the page and opened by your own add-to-cart handler.

That is a feature, not a gap. A Framer drawer can animate exactly how you designed it, show whatever upsell logic you want, and open on the same interaction model across the whole site. But it also means the drawer is only as trustworthy as the cart behind it. A drawer reading local state is a convincing animation attached to nothing, which is the worst of both worlds: it looks finished and it loses orders. Build the cart first, then the drawer.

What does the cart hand to Shopify checkout?

The cart object carries a checkoutUrl. Send the buyer there and Shopify takes over: payment, taxes, shipping, fraud, and the rest of a checkout you do not want to reimplement. What you can and cannot change past that point is its own topic, covered in guest checkout from a Framer site.

This handoff is also where recovery lives, and the mechanics are worth getting exactly right. The abandoned checkout is created by the checkout, not by the cart: Shopify considers a checkout abandoned when it stays incomplete for more than ten minutes after the customer has provided their email information. A cart that never existed in Shopify cannot reach a checkout, so it cannot produce that record — and with the average documented cart abandonment rate sitting at 70.22% across 50 studies, giving up recovery entirely is not a small concession.

Worth checking rather than assuming: Shopify's own help article scopes automated recovery emails to the Online Store and Buy Button channels. If recovery email is load-bearing for your store, confirm in the admin that your headless checkouts are producing recoverable records before you rely on them, and plan the flow deliberately — we walk through that in abandoned cart email from a Framer storefront.

The build order that works

Cart object first, then persistence, then the drawer, then the handoff. Teams that reverse it — drawer first, because it demos well — rebuild the whole thing the week a real customer loses a basket. Framer is the right place to design the cart. Shopify is the only right place to store it. Tools like FramerLink exist to keep that split clean, but the split itself is the part that matters.

Frequently asked questions

How does a cart work on a Framer site connected to Shopify?

The cart is created inside Shopify through the Storefront API, and the returned cart ID is stored in the browser. Framer renders the interface — product grid, drawer, quantity controls — while Shopify owns the line items, pricing and inventory. The same cart is then handed to Shopify checkout through its checkoutUrl.

Why do items disappear from my cart when I change pages?

Because the cart lives only in component state. Framer unmounts that state on navigation, so the items are gone. A cart that exists as a Shopify object survives navigation: the page reloads, reads the saved cart ID, and queries Shopify for the current contents.

How long does a Shopify cart last?

Shopify documents that unused and abandoned carts automatically expire within 30 days of creation, and that the cart is deleted once the customer completes checkout. A shop can create an unlimited number of carts, so there is no reason to reuse or recycle a stale cart ID.

Can a Framer storefront use a cart drawer instead of a cart page?

Yes. The drawer is purely a Framer layout concern — an overlay component reading the same cart state. Unlike a Liquid theme, where the drawer is a theme setting, in Framer you build the overlay yourself and decide when it opens, which is why the underlying cart has to be real.

Does a headless Shopify cart still create abandoned checkouts?

The abandoned checkout is created by the checkout, not the cart. Shopify records one when a checkout stays incomplete for more than ten minutes after the customer provides email information. A cart that never reaches Shopify cannot produce that record at all.

Sources