CLS Cumulative Layout Shift in Next.js, stabilize your layout (2026)

cls5 min readNovember 27, 2026

Author: DevStudio.it

TL;DR

CLS measures how much content jumps while the page loads and during the visit. On a Next.js service site the usual culprits are images without dimensions, late fonts, cookie banners, lazy embeds, and dynamic above-the-fold blocks. 2026 target: CLS ≤ 0.1 (good) in mobile CrUX. Below: diagnosis, space reservation, next/image + fonts, a pre-launch checklist, and App Router pitfalls.

Who is this for

  • Next.js teams with red CLS in PageSpeed / CrUX
  • Companies after a redesign where “it looks good but everything jumps”
  • SEO owners treating Core Web Vitals as a quality signal
  • Developers shipping cookie banners, chat, and third-party scripts
  • Agencies delivering service sites with hero and case study media

Keyword (SEO)

cls nextjs, cumulative layout shift 2026, core web vitals cls, next/image dimensions, font swap cls, layout shift cookie banner

What CLS actually measures

CLS sums unexpected layout shifts over the observation window (including the user session, not only first paint). An element that appears inside a reserved box, or as a direct result of user input, is treated differently from a jump with no cause.

Result Threshold (CrUX) Business meaning
Good ≤ 0.1 Stable UX, fewer CTA misclicks
Needs improvement 0.1-0.25 Often hero + cookie + fonts
Poor > 0.25 Users chase moving buttons

Google ranking care about field data (CrUX). Lab (Lighthouse) is for debugging, not a substitute for RUM.

Common CLS sources on a service site

  1. Hero image / background without width/height or aspect-ratio
  2. Web fonts with late swap (FOUT shifting headlines)
  3. Cookie / consent banner injected above content after hydrate
  4. Chat widgets, reviews, maps, YouTube without placeholders
  5. Ads / partner logos loading late
  6. Dynamic CMS blocks (A/B, personalization) above the fold
  7. Icons / sprites appearing after JS
  8. Late CSS (incomplete critical CSS, FOUC)

Case studies and galleries from Branchly must leave the CMS with known media dimensions, or every new cover image can regress CLS.

Next.js Image, reserve the box

next/image helps when you set dimensions or use fill inside a ratio-locked container:

import Image from 'next/image';

export function Hero() {
  return (
    <div className="relative aspect-[16/9] w-full">
      <Image
        src="/hero-office.jpg"
        alt="DevStudio office"
        fill
        priority
        sizes="100vw"
        className="object-cover"
      />
    </div>
  );
}

Rules:

  • Above the fold: priority (LCP), but always a reserved box
  • Remote images: remotePatterns + known aspect from CMS
  • Avoid height: auto on &lt;img&gt; without a CSS ratio
  • Skeleton / blur placeholder is fine if the final size matches

Fonts without typography jumps

next/font self-hosts and improves control:

import { Inter } from 'next/font/google';

const inter = Inter({
  subsets: ['latin', 'latin-ext'],
  display: 'swap',
  adjustFontFallback: true,
});
Practice CLS impact
next/font + adjustFontFallback Smaller metric jump
size-adjust / fallback metric matching More stable H1
Avoid late @import from Google CSS Less late layout
Fixed line-height on hero Less reflow on swap

Do not load three display families “just in case” in the first viewport.

A consent bar above content after 1-2 s is classic bad CLS. Prefer:

  • A reserved slot (sticky bottom with min-height), or
  • Overlay / modal that does not push content
  • Idle loading, but still reserved space if the banner is in-flow
Pattern CLS risk Note
Top banner, in-flow, late High Worst UX + metric
Bottom sticky with min-height Low/medium Slot reserved
Modal / overlay Low Does not shift layout
Chat bottom-right absolute Low Does not push content

Fast TTFB hosting (DevStudioIT Cloud) will not fix CLS alone: a script can still inject DOM without a box.

Diagnosis, lab vs field

  1. CrUX / GSC Core Web Vitals: ranking truth
  2. PageSpeed Insights: lab + field when available
  3. Chrome Performance / Experience: Layout Shift regions
  4. Web Vitals extension + web-vitals in RUM
  5. Lighthouse CI in PRs (catch regressions before merge)
// simplified RUM hint
import { onCLS } from 'web-vitals';

onCLS((metric) => {
  // send to analytics / logs
  console.log(metric.name, metric.value, metric.entries);
});

Inspect the largest sources in each entry: which node moved and by how much.

Pre-launch checklist

  1. Every above-the-fold image has ratio / dimensions
  2. Fonts via next/font, fallback tuned
  3. Cookie and chat do not push the hero
  4. Embeds ship with fixed-height placeholders
  5. No late CSS unlocking layout after first paint
  6. Dynamic sections below the fold or skeleton-matched height
  7. Test mid-tier mobile + throttling
  8. Compare CrUX 28 days after deploy (not only local Lighthouse)
  9. CMS media (Branchly) includes width/height metadata
  10. Deploy on stable edge (DevStudioIT Cloud), measure field, not only lab

Common mistakes

  1. “Lighthouse 100 here, CrUX red”: lab ≠ users on slow 4G
  2. Images with only width: 100% and no aspect-ratio
  3. Cookie banner injected above H1 after hydrate
  4. Font via CDN @import in global CSS
  5. A/B test changing hero height without reservation
  6. Lazy mid-article component without min-height
  7. Ignoring iframes (maps, booking calendars)

FAQ

Does CLS affect SEO in 2026?

Yes, as part of Core Web Vitals (page experience). Weak CLS rarely “kills” rankings alone, but in competitive SERPs and with similar content, UX quality matters. CTA misclicks hurt conversion immediately.

Does loading=&quot;lazy&quot; cause CLS?

Lazy itself does not. Missing reserved space when the image appears does. Always use a known height / ratio box.

What about animations?

Transform/opacity are fine. Animating top/height/margin on in-flow elements causes shift. Prefer transform.

App Router vs Pages, does CLS differ?

Same metric. App Router can be sensitive to late client components and streaming: do not stream an above-the-fold block that changes height after hydration.

CTA

Red CLS on mobile, or a jumping hero after cookie/chat? We will measure CrUX, fix the layout, and add monitoring.

Related posts

Typography and Web Fonts in Next.js, next/font, Subsetting, and CLS Without Regression (2026)
6 min read
Performance Budget and Core Web Vitals for Teams, Lighthouse CI in Practice (2026)
5 min read
Lighthouse CI, automated Next.js performance audit in GitHub Actions (2026)
9 min read

About the author

We build fast websites, web/mobile apps, AI chatbots and hosting setups — with a focus on SEO and conversion.

Recommended links

From theory to production — Branchly, our hosting stack and shipped work.

Like how we think? Let's build something together.

Start project configuration