Justine Acosta
JUSTINE ACOSTA · GMT+8 ·
All articles
BLOG / ARTICLE

Making a Next.js App Genuinely Fast

Performance work goes wrong when it starts from a score instead of a budget. Here's what actually moves the numbers users feel, in rough order of payoff.

6 min readPerformanceNext.jsCore Web Vitals

Most performance work starts with a Lighthouse score and a vague sense that the number should be higher. That's a reasonable instinct and a poor plan: it optimizes for the measurement rather than the experience, and it tends to produce a lot of effort spread across things nobody notices.

A better starting point is a budget: how long, on a mid-range phone over mobile data, before the user sees the thing they came for? Pick a number, measure against it, and spend effort where the gap is.

Measure what users actually experience

Lab scores on a developer laptop over office wifi are not representative of the people you're serving. They're useful for catching regressions, not for understanding where you stand.

Field data is the real signal: Search Console and Vercel Analytics both surface it. Two metrics carry most of the weight:

LCP is when the main content appears. This is the one users describe as "slow" and it's where most of the available improvement lives.

INP replaced FID and measures how quickly the page responds to interaction. This is usually a JavaScript problem: too much of it, running at the wrong time.

CLS matters too, and it's typically an easy fix: reserve space for images, ads, and anything that loads late.

Look at the 75th percentile, not the average. Averages hide the slow experiences that generate complaints.

Keep the client boundary low in the tree

This is the highest-leverage decision in an App Router codebase, and it's architectural rather than a tuning knob.

A "use client" directive doesn't just affect that component: everything it imports goes to the browser too. Placing it near the top of a page sends the whole subtree, and the page becomes a client-rendered app with server-rendering overhead on top.

The pattern that keeps bundles small is pushing the boundary down to the leaves that genuinely need it, and passing server-rendered content through as children:

// Server component: data and content stay on the server.
export default async function Page() {
  const posts = await getPosts();
  return (
    <Reveal>
      <PostList posts={posts} />
    </Reveal>
  );
}

Reveal handles the animation and ships to the client. PostList renders on the server and arrives as markup. A client component that receives children doesn't pull those children into its bundle: worth internalizing, because it resolves most "this needs to be interactive" situations without giving up server rendering.

Fix the loading of images and fonts first

These two account for most LCP problems, and both have well-worn solutions.

Images: use next/image with explicit dimensions, set priority on the one above the fold and only that one, and serve modern formats. An unoptimized hero image is regularly the single largest contributor to a bad LCP.

Fonts: next/font self-hosts and eliminates the render-blocking request to a font CDN, along with the layout shift that follows. A raw @import in CSS costs you a connection to a third-party origin before any text can paint.

Neither is subtle work, and together they often close most of the gap on a site that has never had performance attention.

Look for request waterfalls

Server components make data fetching easy to write and easy to serialize by accident. Sequential awaits produce a waterfall where each request waits for the one before it:

const user = await getUser(id);
const posts = await getPosts(id);      // waited for user unnecessarily
const settings = await getSettings(id); // waited for posts

If the calls don't depend on each other, start them together:

const [user, posts, settings] = await Promise.all([
  getUser(id),
  getPosts(id),
  getSettings(id),
]);

Three round trips become one round trip's worth of latency. On a page with several independent data sources this is frequently the largest single improvement available, and it's a five-line change.

Where one slow query genuinely blocks a section, Suspense lets the rest of the page stream while that part resolves, so the user sees most of the page immediately.

Give third-party scripts a strategy

Analytics, chat widgets, tag managers, and session recorders are usually added without much thought and are collectively one of the largest costs on a typical site: often more than the application code.

Load them through next/script with a deliberate strategy: afterInteractive for things that can wait, lazyOnload for anything that isn't needed until the user does something. A chat widget loading before your content is a real cost paid on every visit for a feature a small fraction of visitors use.

It's worth periodically auditing what's on the page. Scripts accumulate, and the tag someone added for a campaign two years ago is often still loading.

Render statically wherever you can

Static generation is the fastest thing available: HTML served from a CDN with no computation. Next renders statically by default when nothing forces otherwise, and it's easy to opt out by accident: reading headers or cookies in a layout makes every page beneath it dynamic.

Asserting the rendering mode in code makes that visible instead of silent:

export const dynamic = "error"; // build fails if a dynamic API sneaks in

For content that changes on a schedule rather than per request, incremental regeneration gives you static delivery with a revalidation window. Genuinely per-user pages should be dynamic: the goal isn't to make everything static, it's to be deliberate about which pages aren't.

Keep it fast after it's fast

Performance regresses quietly. One import pulls in a large dependency, one "use client" moves up a level, and six months later you're back where you started with no single commit to blame.

Two habits prevent most of it. Put a bundle size check in CI that fails on a meaningful increase: the number matters less than the conversation it forces. And glance at field data monthly rather than waiting for someone to report that the site feels slow.

Rough order of payoff

For a typical Next.js app that hasn't had this attention:

  1. Image optimization and next/font.
  2. Parallelize data fetching that's accidentally sequential.
  3. Move client boundaries down; check what's in the bundle.
  4. Give third-party scripts a loading strategy.
  5. Confirm pages that could be static actually are.
  6. Add the CI bundle check so it stays fixed.

The first two are usually a day and produce most of the visible improvement. The rest is worth doing, in that order, and none of it requires a rewrite.