Free

Next.js · Headless Commerce · Performance

Notes from taking a monolithic WooCommerce storefront headless — TTFB, IDOR, multilingual SEO, and the animation library we didn't need.
October 20, 2026·7 min read

What We Learned Decoupling WooCommerce Behind Next.js 16

#Next.js#Headless Commerce#Performance#Security

Marine Part System sells boat-engine parts across four European markets, and like a lot of WooCommerce stores that grow past a certain catalog size, it had started to show its age: Time to First Byte creeping past 1.8 seconds, CPU throttling on shared hosting during seasonal traffic, and a multilingual setup that was one wrong canonical tag away from a duplicate-content penalty. Decoupling the frontend with Next.js 16 while keeping WooCommerce purely as a headless catalog backend solved most of this — but a few of the specific fixes are worth writing down.

The order-ID leak nobody notices until it's reported

WooCommerce's default order-received and thank-you routes use sequential order IDs. That's invisible until someone realizes they can increment the number in the URL and see another customer's name, address, and phone number. The fix wasn't complicated — a getOrderForPublicView(id, key) function doing a constant-time comparison (timingSafeEqual) against the order's unique key, returning an identical 'not found' response whether the ID is wrong, the key is missing, or both — but it's the kind of thing that's easy to skip when a headless migration is framed purely as a performance project.

Replacing Framer Motion with 40 lines of math

Framer Motion is a fine library, and for most projects the 30kB it adds to the bundle isn't worth worrying about. On a storefront where a meaningful share of visitors are marina technicians on mobile connections, it was. The mobile drawers and bottom sheets didn't need a general-purpose animation engine — they needed a spring. A small damped-harmonic-oscillator loop, written directly against requestAnimationFrame and applied straight to DOM refs, replaced it entirely, at zero added dependency weight.

This isn't an argument against animation libraries generally. It's a reminder that 'we need animation' and 'we need this specific library' are different claims, and the gap between them is sometimes 30kB of JavaScript a user has to download before they can add a part to their cart.

Headless SEO has its own failure mode

Rank Math's REST API is built assuming the WordPress install is also the public-facing site, so its canonical URLs pointed at the backend WordPress domain instead of the actual storefront — invisible in the WordPress admin, and quietly wrong in every page's <head> once the frontend went headless. A small merge function with explicit domain guardrails (checking whether a canonical actually belongs to the storefront's own domain before trusting it) fixed it, but it's a failure mode that only shows up once you've already shipped, which is worth knowing going in.

Results

TTFB dropped from over 1.8 seconds to under 120ms. All four locales — English, German, Dutch, and Spanish — hit a 100/100 Lighthouse SEO score. The order-ID issue is closed entirely. None of it required a rewrite of the product catalog or the checkout logic in WooCommerce — just a frontend that didn't trust the backend's defaults blindly.

Got something you're building?