Webulux
Back to all articles
Architecture16 min readBy Muhammad Usama

Next.js Headless Shopify: When to Migrate and When to Stay on Liquid

TL;DR: The Quick Read

Next.js fixes two distinct problems Liquid can't: server-generation overhead and heavy interactive asset execution. Most stores that think they need headless are actually running unoptimized Liquid with ghost scripts, not hitting a real architectural ceiling. Diagnose which wall you're facing before committing to a rebuild.

  • Run the general checklist first: start with the broader when to go headless framework before deciding Next.js specifically is the answer.
  • Rule out script bloat: a 5-second LCP is often just ghost scripts or Shopify app bloat, fixable in a two-week sprint, not a five-month migration.
  • Check for a genuine rendering ceiling: if Time to First Byte stays above 600ms on a clean theme, or your catalog needs logic Liquid architecture can't model, that's a real signal.
  • Weigh non-Shopify integration and scale: a CRM-coupled stack or international latency needs can justify Next.js over Hydrogen even without a severe bottleneck.

The DevTools waterfall told the story before we said a word out loud. A B2B SaaS platform, TTFB crawling past a full second, LCP sitting at 5.6 seconds. The instinct is to blame the usual suspects: unoptimized images, unminified CSS, a bloated hero section. We traced it instead. The delay lived before the browser ever got involved. Every page request was hitting a heavily plugin-stacked WordPress instance, generating output fresh, every single time, for every single visitor.

Three weeks later, a completely different problem. A lab-grown diamond brand, building from zero, no legacy bloat to strip. The wall showed up the moment we specced the product experience: 4K imagery, 360-degree interactive viewers, live pricing that updates as a customer changes cut and clarity. Stack that on standard Shopify apps and Liquid, and every one of those apps injects its own JavaScript. On mobile, that's an instant freeze before the customer even sees the diamond.

Same conclusion. Completely different diagnosis. That's the thing almost nobody writing about headless commerce gets right: they treat "should we go headless" as a single yes-or-no question, when the real question is which specific architectural wall you're hitting, and whether Next.js is even the right tool for that wall. Our earlier post on when to go headless covers the general checklist: revenue myths, the architectural breaking point, the operational cost. This post goes one level deeper. It's about Next.js specifically, the hard thresholds that justify it, and the two migrations, one server-side and one asset-heavy, that prove the thresholds are real.

The Problem: Headless Gets Treated as One Decision

Every SERP result for this topic collapses into the same shape. A three-question filter. A cost table. A "here's what breaks" section. Useful, but generic. None of them separate the reasons a store needs Next.js from the reasons it needs Hydrogen, and those are not the same reasons. Hydrogen is Shopify's own React framework: tight Storefront API integration, native Oxygen hosting, built for commerce-first builds where the frontend and the backend both live inside Shopify's world. Next.js is a general-purpose framework. It wins when you need something Hydrogen was never built for: deep integration with a CRM that already runs on Next.js, editorial content systems, or a server-rendering bottleneck that has nothing to do with the storefront itself.

Most merchants never get that far. They show up convinced they need headless because a competitor migrated, or because their store "feels slow," and the actual diagnosis takes fifteen minutes in DevTools. More often than not, the fix is a cleanup sprint, not a five-month rebuild. That's the pattern our architectural limit framework already covers at a high level. What follows is the specific, numbers-attached version for Next.js.

The Counter-Intuitive Insight: The Ceiling Isn't Always Liquid

Here's what surprised us on the B2B SaaS engagement. The client asked us to optimize their existing setup first. We looked, and the architecture itself had reached diminishing returns. Not because Liquid was bloated, this wasn't even a Shopify store yet, but because the pattern we see everywhere on Shopify (dead code, unnecessary server work, nested loops recalculating things that never change) showed up here too, just on WordPress instead. Multiple agencies had layered page builders, dual analytics platforms, webinar integrations, and CRM connectors on top of each other. The server was generating pages dynamically for every visitor because nobody had ever asked whether it needed to.

The tell wasn't a scary LCP number. Plenty of stores post a 5-second LCP and it's completely fixable with an afternoon of ghost script removal. The tell was that the bottleneck lived in how the page got generated, not how it got delivered. You can't cache your way out of that when the marketing team needs to keep publishing pages dynamically. That's a structural constraint, and it's the exact line that separates "optimize the theme" from "the architecture is the ceiling."

The diamond brand's wall looked nothing like that. This wasn't rendering overhead. It was asset execution. Build a product page that needs 4K photography, a 360 viewer, and live-updating pricing using standard Shopify apps stacked on Liquid, and every app injects its own JS. On a mobile browser, that's a freeze before the customer sees anything. The realization wasn't "Liquid is slow." It was that the assets this product category needs to sell itself are the exact assets that will kill the page if rendered the naive way. That's an execution-sequencing problem, not a template-efficiency problem, which is why the fix wasn't "compress the images harder." It was building progressive asset delivery where the heaviest components stay completely dormant until the customer actually interacts with them.

The Hidden Problem: Mistaking Neglect for a Ceiling

This is the misdiagnosis we run into most, and it cuts both ways. Most brands who show up already convinced they need Next.js are carrying years of technical debt nobody has ever properly audited. We've talked people out of headless migrations more often than we've talked people into them.

The tell is always the same. Throttle Chrome DevTools to Fast 4G, reload the homepage, and watch the waterfall fill with a dozen-plus third-party scripts firing before the hero image even starts, several of them from apps uninstalled years ago. That's not an architectural wall. That's an unmaintained storefront. A merchant tells us "our store is slow, we need to go headless," and what they're actually describing is hundreds of kilobytes of dead JavaScript still executing on every load because nobody cleaned up after removing old review widgets and popup tools. You don't need a rebuild to fix that. You need someone to open the theme files and delete what shouldn't be there. The full mechanism behind why this happens, and how much it typically costs, is in our breakdown of Shopify app bloat.

The way we tell the two apart in practice: we ask what the team's actual roadmap requires. If the answer is "we need our developers to stop fighting the platform to ship basic features," and every sprint retro has someone saying "Shopify won't let us do that," that's a real architectural ceiling. If the answer is "the store feels slow," that's a diagnostic question, not a migration decision. We've had prospects arrive dead certain they needed headless because a competitor announced theirs, and when we ran the actual numbers, Liquid render times in Theme Inspector, TTFB, script count, the entire problem was fixable in a two-week sprint for a fraction of the migration cost.

The Decision Framework: Four Measurable Gates

Skip the vibes-based checklist. Here are four gates with actual numbers attached, built from what we've seen break in production, not from a generic best-practices list.

Gate 1: Server-generation overhead, not asset weight. If your Time to First Byte is consistently above 600 milliseconds on a clean theme with no ghost scripts, and the delay is server-side, not caused by third-party JavaScript, you're looking at a genuine rendering bottleneck. This is the B2B SaaS pattern: the server does real work on every request (personalization logic, dynamic content assembly) that a static or edge-rendered architecture would eliminate entirely.

Gate 2: Catalog or content complexity Liquid can't cleanly model. Once a catalog needs per-customer pricing tiers, multi-warehouse routing logic, or deeply nested content relationships that Liquid's templating model wasn't built for, you start writing workarounds instead of features. That's the B2B and multi-tenant pattern specifically, not a general "big catalog" rule. A 400-product apparel store with clean variants doesn't qualify. A platform with customer-specific catalogs and pricing logic often does.

Gate 3: Non-Shopify system integration. This is the single clearest justification for Next.js over Hydrogen specifically. If the frontend needs to sit on the same stack as an existing CRM, internal tooling, or a Next.js codebase your engineering team already maintains, Hydrogen's tight Shopify coupling becomes a liability instead of an asset. Hydrogen wins when the build is commerce-first and self-contained. Next.js wins when commerce is one integration among several.

Gate 4: Asset execution requirements above what apps can deliver safely. High-ticket, visually complex product categories, think configurators, 360 viewers, real-time pricing, hit this gate. The test isn't "do we have nice photos." It's whether the experience needs interactive, heavy media that must stay completely inert until a customer engages with it, the exact pattern from the diamond build.

If none of your four gates are true, the fix is almost certainly Liquid architecture work, not a rebuild. Our Liquid bloat breakdown covers exactly what that looks like at the code level.

The Gut-Check Test You Can Run This Week

Don't start with a checklist. Start with the Shopify Theme Inspector, available through the Shopify CLI or Chrome extension, and look at your actual server-side render times per section. If most sections render in well under 100 milliseconds and your slowest offenders are isolated to one or two templates, that's a fix measured in days, not a migration measured in months.

Pair that with one more number. Open Chrome DevTools, throttle to Fast 4G, and count how many third-party scripts load before your hero image appears. More than five or six is very likely ghost scripts and app bloat, not a platform ceiling.

The actual test that separates the two: pull up your last two or three product roadmap items that got deprioritized or scoped down. For each one, ask honestly, was it deprioritized because Shopify's rendering model structurally couldn't support it (personalization that needs to run per-user in real time, a genuinely novel checkout flow, multi-region storefronts with independent deploy cycles), or because your existing theme was too fragile to safely add anything else to it? The first answer means you're a real headless candidate. The second means fix the foundation first, because a Next.js rebuild on top of the same undisciplined engineering habits just gives you a faster way to accumulate the same debt.

Proof: What Two Completely Different Walls Look Like in Production

The B2B SaaS platform was stuck at a 1.82 percent conversion rate on an $18,000 to $30,000 average contract value, which meant every lost demo request was a serious financial hit. The team blamed lead quality. Marketing blamed messaging. The real problem was architectural: a heavily customized WordPress build had accumulated years of page builders, dual analytics, webinar integrations, and CRM connectors, and because the server generated pages dynamically for every visitor, TTFB was crawling and LCP sat at 5.6 seconds. Late-loading testimonial widgets caused layout shifts right as high-intent prospects tried to tap "Book a Demo" on mobile, the same failure mode we cover in checkout optimization, just applied to a lead-gen form instead of a cart.

We migrated the frontend to Next.js using Static Site Generation and Incremental Static Regeneration, bypassing dynamic server rendering entirely so the site could load from global edge networks. We layered a headless CMS on top so marketing could keep publishing without developer intervention, and rebuilt the demo-booking flow as a five-step progressive form wired directly into HubSpot. Forty-five days from kickoff to production. LCP dropped from 5.6 seconds to 1.7 seconds. Conversion rate moved from 1.82 percent to 2.93 percent. Qualified demo requests went from 118 a month to 190. Based on historical close rates, that generated roughly $82,000 in additional monthly pipeline. Full numbers are in the B2B SaaS case study.

The diamond brand had a completely different starting point: zero historical sales, built from scratch. The technical paradox of high-ticket jewelry is visual weight. Massive 4K imagery, close-up zoom, interactive 360-degree viewers, all of it necessary to close a purchase a customer can't physically touch. Standard Shopify apps stacked on Liquid would have frozen the mobile browser before the customer even saw the product. We converted all media to AVIF and WebP, engineered the 360 viewer to stay completely dormant until a customer interacted with the gallery, and built a native ring configuration system so pricing updated live without page jumps.

LCP dropped from an unoptimized 4.8 seconds to 1.3 seconds. During the initial launch, a $10,000 Meta budget generated over $25,000 in revenue. Scaling to $20,000 combined Meta and Google spend took the brand past $50,000 a month within 90 days, from zero. Full breakdown in the lab-grown diamond case study. Two brands, two completely different technical failures, the same LCP metric moving in the same direction once the actual bottleneck got identified instead of guessed at.

The Part That Never Makes the Case Study

The clean before-and-after numbers hide the execution risk. On the diamond build, the instinct was to build the 360 viewer once and let it initialize like everything else on the page. Do that, and you're asking every visitor's browser to prepare an entire interactive image-sequence experience, most of whom will never touch it. We had to build a deliberate two-stage loading pattern: gallery thumbnails load in the background after the hero image renders, and the 360 viewer's JavaScript, image sequence, and interaction controls don't initialize at all until the customer explicitly clicks into that view. Simple to describe. In practice it meant restructuring how the whole product template thought about "loaded" versus "ready," because most product templates assume everything visible should be interactive the moment it renders.

On the B2B SaaS side, the thing that fought hardest wasn't the frontend rebuild. It was the conversion flow tied to the CRM. An 11-field demo request form, built by a previous agency, assumed synchronous submission and a page reload. Moving to Next.js meant that flow had to become a multi-step, client-side progressive form that still fired the same HubSpot events reliably without breaking existing lead-scoring logic on the sales side. That's integration work that never shows up in a before-and-after LCP chart, but it's exactly the part that breaks silently if nobody's watching for it. A beautiful fast frontend that quietly stops sending leads to sales is worse than the slow version it replaced.

This is also where Next.js earns its keep over Hydrogen specifically. Hydrogen is built to talk to Shopify's Storefront API cleanly. Neither this B2B build nor a heavy CRM-integrated storefront needs that Shopify-native tightness nearly as much as it needs a framework that plays well with a non-Shopify backend system. That's the same architectural tension we cover when explaining why you can't cleanly split a Shopify theme in half: once the frontend's responsibilities extend past commerce alone, a general-purpose framework earns its complexity.

The Honest No: The Client We Talked Out of It

A Shopify Plus merchant, mid seven figures in revenue, came to us fully decided on a headless migration after watching a competitor announce theirs. Their internal pitch to leadership was already written. When we audited them, the profile looked nothing like the B2B SaaS or diamond cases: no server-generation bottleneck, no product category demanding heavy interactive assets, no roadmap items structurally blocked by Shopify.

What we found instead was a theme carrying roughly a decade of accumulated app history: duplicate analytics implementations, three popup tools stacked on top of each other, and a catalog structured so every color and finish of the same item lived as a completely separate product listing instead of a variant, quietly fragmenting sessions and killing continuity every time a customer tried to compare finishes. That exact failure pattern is what we cover in depth in our breakdown of broken catalog architecture, because it's far more common than most merchants realize, and it looks identical to an architectural ceiling from the outside.

We told them not to migrate. That's a hard conversation when a client has already built internal buy-in around a bigger, more exciting project. We reframed it as a technical cleanup sprint instead: stripped the redundant apps, consolidated the catalog into proper variants, rebuilt recommendation logic that had turned into a Liquid loop scanning the entire collection on every page load. Load time and conversion improved substantially within weeks, on their existing native theme, for a fraction of what a full frontend rebuild would have cost.

Had they gone headless anyway, the honest outcome is they'd have shipped a faster-looking storefront that still had a fragmented catalog and the same underlying discipline problems, just rebuilt in React instead of Liquid. Headless doesn't fix bad information architecture or accumulated technical debt. It just gives you a more expensive place to keep making the same mistakes. That's the line we say out loud to every prospect now: the migration is the right call when the platform is the constraint, not when the platform is just where your neglect happens to be visible.

The Practical Framework

Before you spend five months and a six-figure budget, run this sequence in order.

Step one: measure, don't guess. Open Theme Inspector, throttle DevTools to Fast 4G, and check your Interaction to Next Paint alongside TTFB and LCP. Put actual numbers next to your assumption.

Step two: separate script bloat from server-generation overhead. If the delay lives in third-party JavaScript execution, that's a cleanup sprint. If it lives in server-side rendering work that repeats identically for every visitor, that's a genuine architectural signal.

Step three: check for non-Shopify integration needs. If your roadmap depends on tightly coupling the storefront to a CRM, internal tooling, or a system your engineering team already maintains outside Shopify, that alone can justify Next.js over Hydrogen even with a moderate rendering bottleneck.

Step four: run the revenue math. A migration is an investment decision, not a technical preference. Multiply your current sessions by the gap between your actual conversion rate and your category benchmark, the same four-input formula we walk through in how to measure Shopify conversion rate, and compare that recurring monthly gap against the cost and timeline of the rebuild. If the migration doesn't clear that bar inside a reasonable payback window, the honest recommendation is to fix the foundation instead.

Step five: if you're expanding internationally, factor it in separately. A centralized Shopify theme physically punishes distant buyers with added latency regardless of how clean your code is. If multi-region expansion is genuinely on the roadmap, that's a legitimate architectural driver toward edge-rendered Next.js, covered in detail in how edge rendering fixes international latency, separate from whichever performance problem started the conversation.

Two migrations, two completely different technical failures, both justified by hard numbers, not by a competitor's announcement or a vague sense that the store "feels slow." One prospect talked out of migrating entirely, and a cleanup sprint that outperformed the rebuild they were originally sold. That's the difference between diagnosing an architecture and reacting to a symptom.

If you're staring at a slow store and can't tell which side of the line you're on, that's exactly the diagnostic we run before recommending anything.

Is Headless Right for Your Store?

We run the Theme Inspector trace, the DevTools script audit, and the server-generation check before recommending anything. Free technical assessment, no sales pitch, an honest answer either way.

Get Your Free Technical Assessment →
Muhammad Usama
Article by

Muhammad Usama

Founder & Head Conversion Engineer

Founder & Head Conversion Engineer with 8+ years of technical engineering experience. I bridge the gap between full-stack development and e-commerce growth, specializing in tearing down Shopify architectures, eliminating code-level friction, and building high-performance infrastructure for 7- and 8-figure brands.

They Added to Cart. Why Didn't They Buy?

Checkout friction is the most expensive leak in your store. We'll map your entire checkout flow to find the exact technical hurdles causing your users to abandon their carts.

Audit My Checkout Flow →
Get Free Audit