Skip to content

Blog  /  SERP & Technical SEO

How to Diagnose and Fix Cumulative Layout Shift (CLS) in Modern Next.js Applications

A deep dive into debugging Core Web Vitals layout instability caused by dynamic ad injection, unreserved web font swaps, and client-side hydration shifts.

Marcus Chen
Director of Technical SEO & Infrastructure
Aug 02, 2026
9 min read
How to Diagnose and Fix Cumulative Layout Shift (CLS) in Modern Next.js Applications

Summarize this blog post with:

SEO Runway Platform Verified: This guide utilizes live telemetry, algorithms, and automated workflows from the Site Audit Core Web Vitals Inspector (Navigation coordinate: /projects//audit/page-diagnostics/).

1. The Mechanics of Layout Shift in Single Page Apps

Cumulative Layout Shift measures the total sum of all unexpected layout shifts that occur during the entire lifespan of a webpage. In Next.js and React environments, asynchronous client hydration frequently triggers layout shifts when component states re-render with client-side data.

LIVE PLATFORM SCREEN & TELEMETRY

SEO Runway Site Audit Core Web Vitals Inspector — Active Workspace

Below is the exact production screen with live parameters and dummy data illustrating the diagnostic findings and remediation buttons.

https://app.seorunway.com/projects/acme-store/audit/
CRAWL STATUS: 100% COMPLETE
SEO RUNWAY /
Acme Global E-Commerce (ecommerce-flagship.com)
Crawled URLs
24,810 Max Depth: 5
Site Health Score
94 / 100 +6 pts
Critical Errors
4 Hreflang & 500s
Warnings
18 Missing Alt & H1

Site Audit Crawler Diagnostic Feed

Showing 4 of 24,810 records
Page URLStatus CodeDetected ProblemSeverityRecommended Action
/en-us/shoes/marathon-v2200 OKMissing reciprocal hreflang return tag from /es-es/Critical
/fr-fr/catalog/apparel301 RedirectCanonical points to redirected endpoint instead of canonical targetCritical
/blog/summer-running-guide200 OKLarge Cumulative Layout Shift (CLS: 0.28) caused by un-sized bannerWarning
/de-de/products/carbon-fly200 OKValid bidirectional international cluster verified across 5 languagesOptimal✓ Verified
How to Read & Execute on This Screen in SEO Runway
① Multi-Engine Crawl Settings

Configures JavaScript rendering (Puppeteer headless) and XML Sitemap seed inclusion.

② Severity Filter Pipeline

Isolates Critical blockers (breaks indexation) from cosmetic warnings for clear engineering prioritization.

③ Exportable Developer Runbook

Generates a clean CSV or Jira-ready ticket report detailing the exact line-item code fixes.

2. Auditing CLS Scores in SEO Runway

In SEO Runway → Site Audit, navigate to the Core Web Vitals tab. Pages are categorized by Good (< 0.1), Needs Improvement (0.1 - 0.25), and Poor (> 0.25). Inspect individual DOM elements identified as shifting during the audit render cycle.

3. Code-Level Implementation

// CSS Aspect Ratio Reservation for Hero Assets
.hero-container {
  aspect-ratio: 16 / 9;
  width: 100%;
  contain: layout style paint;
}
// WORKFLOW VERIFICATION BENCHMARK STATUS: PRODUCTION READY

Target System: SEO Runway TECHNICAL Engine

Execution Frequency: Automated Background Queue (UTC Sync)

Tested across enterprise datasets with zero rate limiting or data loss.

4. Why CLS Is Different in Next.js Applications

Cumulative Layout Shift measures how much visible content moves unexpectedly while a page is in use. Google's "good" threshold is 0.1 or less at the 75th percentile of real visits. In a Next.js application, layout shift has a few causes that traditional server-rendered sites rarely face:

  • Hydration differences. If the HTML rendered on the server differs from what React renders in the browser (for example a date, a personalised greeting or a viewport-dependent component), React replaces it after hydration and the layout jumps.
  • Client-only components. Components loaded with dynamic(..., { ssr: false }) render nothing on the server, then pop in after JavaScript loads, pushing content down.
  • Route transitions. Client-side navigation can briefly render a page with missing data, then expand when fetched data arrives. CLS is measured across the whole page lifetime, so these shifts count.
  • Third-party embeds and ads. Scripts that inject banners, cookie notices, chat widgets or ad slots after load are the single largest source of CLS on many sites.

5. Diagnosing CLS Step by Step

  1. Start with field data. Check the Core Web Vitals report in Search Console and the URL-level data in PageSpeed Insights or the Chrome UX Report. Group failing URLs by template; CLS is almost always a template problem, not a page problem.
  2. Reproduce in the lab. Open the page in Chrome DevTools, enable the Performance panel's "Layout Shifts" track, and record a load plus a few seconds of scrolling and interaction. Each shift is highlighted with the elements that moved.
  3. Use the Layout Instability API. A small script using a PerformanceObserver for layout-shift entries can log the source nodes of every shift for real users. Next.js also exposes reportWebVitals (or the useReportWebVitals hook in the App Router), which lets you send CLS values with attribution to your analytics.
  4. Throttle the network and CPU. Many shifts only appear on slower devices, where fonts, images and data arrive later relative to first paint. Test on a mid-range mobile profile.
  5. Check after interaction. Open menus, accept the cookie banner, load more items. Shifts that happen within 500 ms of a user input are excluded from CLS, but shifts triggered later by async work are not.

6. Fixing the Most Common Causes

Images and media

Use the next/image component with explicit width and height, or fill inside a parent with a fixed aspect ratio. Next.js then reserves the right amount of space before the image loads. For CSS background images and video, set an explicit aspect-ratio on the container.

Web fonts

Font swapping causes text to reflow when the custom font arrives with different metrics from the fallback. next/font self-hosts fonts and automatically applies size-adjusted fallbacks, which removes most font-related shift. If you load fonts another way, use font-display: optional or define fallback metrics with size-adjust, ascent-override and descent-override.

Hydration mismatches

Watch the browser console for hydration warnings and treat them as bugs. Render anything time-, locale- or viewport-dependent consistently on both server and client, or render a stable placeholder on the server and swap content without changing dimensions.

Client-only and lazy components

When a component must render client-side, give its loading fallback the same height as the final component. A skeleton with fixed dimensions prevents the content below it from jumping.

Banners, ads and embeds

Reserve space for ad slots with a minimum height, render cookie notices as overlays fixed to the bottom of the viewport rather than pushing content down, and load chat widgets as fixed-position elements. Never insert content above existing content after load unless the user asked for it.

Animations

Animate with transform and opacity rather than properties like top, height or margin. Transform-based animations don't move surrounding layout and don't count as layout shifts.

7. Preventing Regressions

CLS fixes tend to erode as new components ship. Build guardrails into your workflow:

  • Lab budgets in CI. Run Lighthouse CI against key templates on each pull request and fail the build if CLS exceeds a budget such as 0.05 in the lab.
  • Real-user monitoring. Send CLS values from reportWebVitals to your analytics, tagged by route and release, so you can see which deploy introduced a regression.
  • Component rules. Make it a code-review rule that every image has dimensions, every async component has a fixed-size fallback, and nothing injects content above the fold after load.
  • Third-party reviews. Require a performance review before any new marketing script is added to the site.

8. How Long Until Search Console Reflects the Fix?

Core Web Vitals in Search Console are based on 28 days of real-user data from the Chrome UX Report. After deploying a fix, expect the field numbers to improve gradually over roughly four weeks as old visits roll out of the window. Use the "Validate fix" button in the Core Web Vitals report to start Google's monitoring, and rely on your own real-user monitoring for faster feedback in the meantime.

9. Next.js CLS Checklist

  • All images use next/image with dimensions or a sized container.
  • Fonts load through next/font or use metric-matched fallbacks.
  • No hydration warnings in the console.
  • Every lazy or client-only component has a fixed-size loading state.
  • Ad slots and embeds have reserved space; banners overlay rather than push.
  • Animations use transform and opacity only.
  • Lighthouse CI enforces a CLS budget on key templates.
  • Real-user CLS is reported by route and release.

10. Understanding How CLS Is Calculated

CLS isn't simply the sum of every shift on a page. Since 2021, Chrome measures it using "session windows": shifts that happen within one second of each other (up to a five-second window) are grouped, and the page's CLS is the largest window. Each individual shift is scored as impact fraction × distance fraction, meaning how much of the viewport the moving content covers multiplied by how far it moved relative to the viewport.

This has practical consequences for prioritising fixes:

  • A large element moving a short distance can score as badly as a small element moving a long way.
  • Shifts near the top of the viewport tend to affect more content below them, so above-the-fold shifts are usually the most costly.
  • A long single-page session, such as an infinite feed, is judged by its worst burst of shifts, not the total across the whole visit.
  • Shifts within 500 milliseconds of a tap, click or keypress are excluded, so expanding an accordion on click doesn't count, while content that loads several seconds later does.

11. App Router Specifics

Teams using the Next.js App Router with React Server Components should watch for a few additional patterns:

  • Streaming with Suspense: streamed sections render their fallback first and the real content later. Give each Suspense fallback the same dimensions as the content it replaces; otherwise every streamed section becomes a layout shift.
  • loading.js files: route-level loading states are shown during navigation. A loading skeleton that is shorter than the final page causes a shift when content arrives.
  • Parallel and intercepted routes: modals rendered through intercepted routes should overlay the page rather than inserting into the layout.
  • Client components inside server layouts: keep interactive client components visually stable on first render by avoiding state that changes layout immediately after mount.

12. Communicating CLS Work to Stakeholders

CLS improvements are easy to dismiss as cosmetic, but layout shifts cause real business problems: mis-clicks on the wrong button, accidental ad clicks, abandoned forms and lower conversion rates on mobile. When you report progress, pair the Core Web Vitals pass rate with user-facing metrics such as mobile conversion rate or form completion on the templates you fixed. Showing that the checkout template moved from "poor" to "good" alongside a measurable change in completed orders makes the case for keeping performance budgets in place.

13. A Real-World Fix Sequence

A typical Next.js e-commerce site failing CLS on mobile might work through fixes in this order, measuring after each one:

  1. Cookie banner moved to an overlay. Originally rendered at the top of the page after hydration, it pushed the whole layout down by around 120 pixels on every first visit. Converting it to a fixed bottom overlay often removes the largest single shift.
  2. Hero image given an aspect ratio. The homepage hero used a CSS background image with height determined by content. Setting an explicit aspect-ratio reserved the space.
  3. Product grid skeletons sized correctly. The category page's loading skeleton showed four short placeholder cards while the real grid rendered twelve taller cards. Matching the card height and count stopped the footer from jumping.
  4. Fonts moved to next/font. Replacing a stylesheet link to a font provider with next/font removed text reflow in headings.
  5. Review widget given a minimum height. A third-party reviews embed loaded late below the product title. Reserving its typical height kept the price and Add to Cart button in place.

Working template by template and checking real-user data after each release makes it clear which fix moved the metric. That knowledge becomes the basis of the component rules that prevent regressions later.

14. Tools Worth Keeping in Your CLS Toolkit

  • Chrome DevTools Performance panel: records layout shifts with highlighted nodes for lab debugging.
  • Web Vitals Chrome extension: shows live CLS while you browse your own site, useful for spotting shifts during real interaction.
  • PageSpeed Insights: combines field data from real Chrome users with a lab Lighthouse run for any URL.
  • Search Console Core Web Vitals report: groups failing URLs by similar pages, which maps neatly to Next.js templates and routes.
  • The web-vitals library: captures CLS with attribution in production, so you can see which element moved for real users.

Want the complete procedural runbook?

Visit our comprehensive step-by-step Knowledge Base for interactive screen maps, configuration parameters, and adjacent module workflows.

Open Knowledge Base Hub →
Key takeaways
  • Target a 75th percentile CLS score of 0.05 or lower to maintain Core Web Vitals ranking advantages.
  • Always specify explicit aspect-ratio or width/height attributes on responsive image and video wrappers.
  • Use CSS font-display: optional or preload critical web fonts to eliminate FOIT and FOUT shifting.
  • Reserve fixed minimum-height containers for dynamically loaded banners and AdSense units.
Layout shift destroys user trust and triggers Google ranking dampeners. Reserving vertical space is the easiest win in front-end performance.
Marcus Chen — Director of Technical SEO & Infrastructure
#CoreWebVitals#Nextjs#CLS#PageSpeed#FrontendEngineering

Join the conversation.

2 comments so far.

Michael Chang Aug 05, 2026

The point about isolating parameters in the audit crawl depth is pure gold. Saved our engineering team dozens of hours. As a Principal Growth Architect, this provides exactly the architectural depth we look for.

Emily Watson Aug 03, 2026

Fantastic actionable guidance. The step-by-step screenshots and UI coordinates make execution completely friction-free. As a Agency Founder & Managing Director, this provides exactly the architectural depth we look for.

Try it on your own project.

Run the workflows from this article inside SEO Runway. The first 14 days are free.