
An optimistic cart with inventory-safe server actions
Fast React UX without promising out-of-stock items
Customers expect instant feedback when they add items to the cart. In a headless Shopify store, cart operations are still real network calls. Without solid UX, the store feels slow even when the backend is fast.
We implemented optimistic UI with React 19’s useOptimistic and Next.js server actions. The screen updates immediately while the real change runs on the server against Shopify. The shopper sees the result before the roundtrip finishes.
At the same time, we cannot promise what we do not have. The server checks inventory and returns clear messages if a variant is out of stock or no longer available. Optimistic state rolls back when reality says no.
The cart layer also handles discount codes, personal offers, and progress toward free shipping. Same cart experience, built for the App Router instead of an Online Store theme.
The balance is the point: fast React UX where it is safe, and strict correctness where inventory and price matter. feelme.no should feel fast without becoming inaccurate.
Want a cart that feels instant without getting inventory wrong? Eon AS builds headless cart in Next.js: snappy for the shopper, correct against Shopify.