Working with Next.js?

Next.js build red, hydrating wrong or half ported to App Router? We finish the job.

Most Next.js codebases that reach us were started on the Pages Router, half moved to the App Router after a sprint planning meeting, and never finished. The build is slow, caching does something different in production than it did in development, and nobody is quite sure which file is the source of truth for a given route. We work through it route by route until the whole app renders the same way twice.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

.next/build.log

still failing

What it is

Next.js at a glance

Next.js is a React meta-framework released in October 2016 by the company then called ZEIT and now called Vercel. It adds file-based routing, server rendering, image and font optimisation, API routes and middleware on top of React, so a team can ship a complete app without first picking ten separate libraries and gluing them together.

Version 13 landed in 2022 and brought the App Router together with React Server Components, which was the largest change to the framework's shape since it launched. Version 14 added Turbopack for the dev server and introduced Server Actions, and version 15 refined the caching defaults so that fetches are no longer cached unless you ask for it. It now powers a large share of modern marketing sites, SaaS dashboards and the output of popular AI builders.

Type
React meta-framework
First released
2016
License
MIT
Maintained by
Vercel and contributors
Typically used for
Marketing sites, SaaS apps, ecommerce frontends, AI-builder output, headless-CMS frontends

The honest version

Next.js pros and cons

No technology is all upside. This is where Next.js earns its place and where it tends to cause trouble.

Where Next.js is strong

  • Every rendering style in one frameworkStatic generation, server rendering, incremental static regeneration, the Edge runtime and React Server Components are all available from the same codebase, and you pick the right one per route rather than per project.
  • File-based routing with layoutsA folder in app/ becomes a URL and a layout.tsx next to it wraps every nested route, so the mental model for new developers is close to how the URLs actually behave.
  • Image and font optimisation out of the boxnext/image resizes and caches images at request time and next/font self-hosts Google fonts without a round trip, which handles two of the biggest performance wins without hand-written code.
  • The Vercel deploy story is genuinely goodA git push gives you preview URLs per branch, automatic CDN caching, and build logs that are easier to read than most CI output, which is why so many teams ship on it.
  • App Router with React Server ComponentsData fetching lives next to the component that renders it, secrets stay on the server, and the client bundle shrinks because read-only screens never reach the browser as JavaScript.
  • API routes and middleware includedSmall backends, webhook receivers and auth checks can live in the same repo as the frontend, which is often enough to avoid standing up a separate Node service.
  • TypeScript is a first class citizenRoute handlers, layouts and page props all have types the framework ships with, and the compiler catches a class of bugs that used to make it to production.

Where Next.js bites

  • Pages Router to App Router is a real migrationData fetching has to be rewritten from getServerSideProps and getStaticProps into async server components, _app and _document become root layouts, and the caching rules are different enough that behaviour you relied on quietly stops being true.
  • Hydration mismatches are a common first bugServer-rendered markup that differs from the client output by even a space throws an error that halts the page, and the usual causes (locale-formatted dates, random ids, reading window during render) are easy to introduce without noticing.
  • Best performance is tied to VercelThe framework runs anywhere that can host Node, but ISR, image optimisation, the Edge runtime and the cache primitives all behave best on Vercel, and reproducing them elsewhere takes real work.
  • Build times grow with the page countA marketing site with a few hundred statically generated routes and a handful of MDX files can turn a cold build into several minutes, which hurts every deploy preview.
  • Server Components confuse teamsThe server and client boundary is implicit until you hit an error, and knowing when to add 'use client', when to pass a component as a child, and where it is safe to read a cookie takes a while to settle in.
  • AI builders generate Next.js that ignores the rulesLovable, Bolt and v0 happily emit App Router code that fetches secrets on the client, skips caching entirely, or mixes server and client components in ways that only fail once the app sees real traffic.

Sound familiar?

Common Next.js problems we fix

The Next.js problems that bring people to us, and what you have once each one is fixed.

Error: Hydration failed because the initial UI does not match what was rendered on the server

Hydration mismatch on first load

The server sends one tree and the browser renders a different one, usually because of a date formatted in the viewer's locale, an id generated from Math.random on render, or a component that reads window before mounting.

Server and client render the same tree

Error: You're importing a component that needs useState. It only works in a Client Component

Server and client boundary in the wrong place

A hook or a browser API crept into a server component, or a 'use client' directive is missing from the file that owns the interactive bit of the page.

Each file on the right side of the line

Error: Dynamic server usage: Page couldn't be rendered statically

A page that should be static is not

Something in the tree reads cookies, headers or searchParams, which forces the whole route to render on every request and quietly loses the caching you thought you had.

Static where it can be, dynamic where it must

next build: Failed to compile (ESM only package in CJS)

The production build will not compile

A dependency went ESM-only, a transform disagrees with the TypeScript config, or a Node built-in was imported from code that runs on the Edge runtime.

Build green on a clean checkout

middleware edge runtime: unsupported module 'child_process'

Middleware fails on deploy but works locally

Middleware runs on the Edge runtime, which does not have the full Node standard library, and a helper imported by a shared module pulls in something that is only allowed on the server.

Middleware kept to what the Edge allows

revalidateTag not called, stale cache served

Content updates but the live site does not

A CMS webhook fires and the cache keeps serving yesterday's data, because no tag was attached to the fetch or revalidateTag was never wired to the webhook endpoint.

Content changes show up when they should

Image Optimization: upstream image response failed with 403

next/image breaks in production

The optimiser cannot reach the origin because the hostname is missing from images.remotePatterns, the storage bucket blocks the optimiser's user agent, or the CDN strips the query string it needs.

Images load through the optimiser again

generated by an AI builder, no caching anywhere

An AI builder shipped it and it fell over at launch

The code works on a demo and dies on day one of real traffic, because auth is mocked, every fetch is uncached, and the server actions write to a database with no index on the lookup column.

Rewritten in the places it had to be

What we do

Next.js help, from migration to upkeep

Call us for one stuck route, or hand us the whole frontend.

App Router migrations
Moving Pages Router code to app/ one segment at a time, with data fetching rewritten, layouts replaced, and the two routers coexisting while the move is in progress.
Hydration and rendering
Tracking down mismatches, sorting server and client components, and getting the right pages back onto static or ISR instead of accidental dynamic rendering.
Build and deploy
Fixing failing production builds, bringing build times down, and getting Next.js to run well on Vercel, AWS, Cloud Run or a plain Node host.
AI-builder cleanup
Taking a Lovable, Bolt or v0 export from a working prototype to something you can actually ship, with auth, caching and a database schema that will survive growth.
Performance
Caching strategy with tags and revalidation, image and font setup, bundle budgets per route, and measurements that mean something to the business.
Managed Tech
Dependency updates, framework upgrades and a team to call, on an ongoing basis.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Next.js alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Next.js questions

Something else? Call+1 737 727 7327

How do we migrate from Pages Router to App Router without a rewrite?

One route at a time, with both routers running side by side. We start with a low-risk page, port its data fetching from getServerSideProps or getStaticProps into an async server component, move its layout up into app/, and ship it to production before touching the next one. The whole migration can take weeks of elapsed time but only hours of downtime risk, because nothing moves until the replacement is proven.

Why does our Next.js site show hydration mismatch errors?

Because the HTML the server sends and the HTML React reconstructs in the browser are not byte-for-byte the same. The usual suspects are locale-dependent date or number formatting, ids generated with Math.random or Date.now during render, components that read window or localStorage before mount, and conditional output based on the user agent. We find the specific mismatch and remove the cause, so the warning does not come back the next time someone touches the file.

Can you deploy a Next.js app somewhere other than Vercel?

Yes. Next.js runs on any host that can run Node, and the standalone output target keeps the container small. Image optimisation, ISR and the Edge runtime all need a little more thought off Vercel, so we usually swap the image loader, use a caching layer in front, and keep middleware simple. For most apps the difference in cost and lock-in is worth the extra configuration.

Why are our Next.js builds slow or timing out on deploy?

Usually a combination of too many statically generated routes, MDX or markdown processing that is not cached between builds, large dependencies pulled into every page, and a CI runner that is smaller than the build needs. We profile what the build is actually spending time on, cache the parts that do not change, split heavy work out of the hot path, and in most cases bring a multi-minute build back under a minute.

Can you fix a Next.js app that an AI builder generated?

Yes, and this is a growing part of the work. Lovable, Bolt and v0 produce code that looks right and runs on a demo, but often ships client-side secrets, skips caching, ignores auth checks, and writes database queries that will not scale past a dozen users. We keep the UI the builder got right, replace the parts that will not survive real traffic, and leave you with a codebase a human can maintain.

How much does Next.js help cost?

Estimates are free. Describe the app and what is going wrong, and you get a price before any work begins.

Free estimate

Next.js project giving you trouble?

Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.