Next.js is not a simple React application. It is a framework that offers at least four different rendering modes (SSR, SSG, ISR and App Router), sometimes on the same page. Each mode can produce a subtly different visual result, for reasons your unit and integration tests will never detect.
According to the State of JS 2024, Next.js is used by 58% of React developers in production. It is the de facto standard for professional React applications, and yet most teams do not have a visual testing strategy suited to its specifics. This guide explains why hydration and rendering modes create regressions that functional tests cannot see, what approaches exist to detect them, and how to integrate them into your pipeline.
The essentials on one page (what a no-code tool really automates and how it compares): No-code test automation.
Key points
- Next.js multiplies rendering modes (SSR, SSG, ISR, App Router) and each one can produce a different visual result for the same page
- React hydration is a major source of visual regressions invisible to traditional functional tests
- Storybook-based approaches do not test the real rendering of your Next.js pages under production conditions
- A framework-agnostic visual testing tool that captures the final result in the browser is the only reliable guarantee
Visual testing means verifying that a software's user interface displays according to the expected visual specifications, by comparing reference screenshots with the application's current state.
When you apply this discipline to a Next.js application, things get considerably more complicated. Next.js is not a simple React application. It is a framework that offers at least four different rendering modes: sometimes on the same page. And each mode can produce a subtly different visual result, for reasons your unit and integration tests will never detect.
According to the State of JS 2024, Next.js is used by 58% of React developers in production. It is the de facto standard for professional React applications. And yet, most teams using Next.js do not have a visual testing strategy suited to its specifics.
Why Next.js makes visual testing more important, not less
A common argument: "Next.js handles rendering for us, no need to visually check every page." That is exactly the opposite of reality.
Next.js makes visual testing more critical precisely because it multiplies rendering paths. With a simple React SPA, rendering was predictable: everything client-side. With Next.js, the same page can be rendered server-side on the first request, then hydrated client-side, then partially re-rendered during client navigation. Each step can introduce a visual discrepancy.
The hydration problem
Hydration is the process by which React takes the HTML generated server-side and "reactivates" it client-side by attaching listeners. In theory, the visual result should be identical before and after. In practice, it rarely is 100%.
The causes: styles computed server-side that do not account for the real window, components that depend on window displaying a fallback in SSR, web fonts not available at server render time causing a FOUT, CSS animations starting at hydration.
Result: a visual gap between what the server sends and what the user sees after hydration. Often subtle: a few pixels of offset, text that redistributes, an image that jumps. But real.
No unit test detects it. Only a visual test, which captures an image of the page rendered in a real browser after full hydration, can confirm that the final result matches what you expect.
The four rendering modes and their pitfalls
Static rendering (SSG) generates HTML at build time. The most predictable, but if your data changes between builds, your pages display stale data.
Server-side rendering (SSR) generates HTML on every request. Dynamic content. The same URL can produce a different rendering depending on the time, the user, the data. Visual testing has to handle this variability, which requires a mocking or stabilization strategy.
Incremental Static Regeneration (ISR) is hybrid: a static page that is regenerated periodically. The pitfall is the transition between the old and the new version. If your layout changed, this transition can be visually inconsistent.
The App Router (Next.js 13+) adds Server Components, streaming and nested layouts. A page mixes Server Components and Client Components. The result is a progressive rendering where content appears in chunks, and each chunk can introduce a visual shift.
Approaches to visually testing a Next.js app
Playwright: brute force
Playwright has a major advantage: it tests the real page, in a real browser, with full rendering (SSR + hydration + CSS + fonts). You capture what the user actually sees.
But Playwright has limits for visual testing. It is a developer tool. You have to write and maintain scripts. On an app with 100 pages × 3 viewports × several states, the maintenance debt explodes. Screenshot comparison is basic (pixel-by-pixel with a tolerance threshold). The baseline infrastructure is your responsibility.
Chromatic via Storybook: the illusion of isolated components
Chromatic captures screenshots of your Storybook components. If you already have Storybook, it plugs in directly.
But for Next.js, there is a fundamental problem: it does not test your pages. It tests your isolated components. Yet the most dangerous regressions do not come from individual components: they come from their interaction, the global layout, SSR rendering, hydration, nested App Router layouts.
A button that displays perfectly in Storybook can break your layout inside a flex container. A navigation component that passes every Chromatic test can cause a cumulative layout shift of 0.3 when loaded via SSR with a web font. Chromatic will never see these problems.
Delta-QA: visual testing of the real page, without code
Delta-QA captures screenshots of your real pages (the ones your users see) and compares them between two versions. Delta-QA does not need to know that you use Next.js, App Router or Pages Router. It captures the final result in the browser, after SSR, after hydration, after fonts load, after client JS runs. What it compares is exactly what your user sees.
This approach solves the three problems: hydration discrepancies are captured, component/layout interactions are visible, and maintenance is minimal.
Next.js specifics and how to handle them
Dynamic content
If your Next.js page displays a real-time counter or a timestamp, every capture differs without any regression. Solution: exclusion zones. You mark the regions with variable content, and the tool ignores them.
Fonts and FOUT
Flash of Unstyled Text is a Next.js classic. Solution: wait for the fonts to load before capturing. The document.fonts.ready API guarantees this. Delta-QA includes this wait natively.
Animations and transitions
Animated components introduce non-determinism. Best practice: disable CSS and JS animations in the visual testing environment. Delta-QA offers this option natively.
Nested App Router layouts
A change in a parent layout affects all child pages. A padding change in the root layout can shift the content of dozens of pages. Without systematic visual testing, you only discover this kind of regression in production. Visual testing covers this surface automatically.
Integrating visual testing into your CI/CD pipeline
You push your code → CI builds and deploys to a preview (Vercel, Netlify) → Delta-QA captures and compares against the production baselines → results in the merge request → team approves or rejects.
This is particularly natural with Vercel, which automatically creates a preview for every branch. Delta-QA plugs into this URL to capture, which means you test your app under near-production conditions.
Metrics to track
Rate of visual regressions detected before prod: the goal is to approach 100%.
False positive ratio: if more than 20% of your detected differences are false positives, your configuration needs refining.
Average review time: if the team spends more than 15 minutes per MR reviewing visual diffs, you are capturing too much noise.
Number of pages covered / total (the goal: 100% of critical pages).
FAQ
Does visual testing replace unit tests for Next.js?
No, it complements them. Unit tests = component logic. Integration tests = components together. Visual testing = the final result matches what is expected. All three are needed.
How do I handle Next.js Server Components in visual testing?
No specific difficulty. Visual testing captures the final result in the browser, agnostic to the rendering mode. This is the key difference from an approach like Chromatic, which requires rendering each component in a specific environment.
How many viewports should I test for a Next.js app?
At minimum three: mobile (375px), tablet (768px), desktop (1440px). Add an intermediate breakpoint if your design changes significantly between tablet and desktop.
Does visual testing slow down my Next.js CI/CD pipeline?
With Delta-QA, capture and comparison run in parallel with the rest of the pipeline. For 50 pages × 3 viewports, allow 2 to 5 minutes: negligible compared with the Next.js build (5-10 min).
Can I use visual testing with Next.js draft mode?
Yes, and it is recommended. Draft mode lets you preview unpublished content from a headless CMS. Visual testing can capture the draft pages to verify that unpublished content does not break the layout before publication.
Does Delta-QA work with Next.js Middleware?
Yes. Middleware runs at the Edge level before rendering. Delta-QA captures the final result after execution. For A/B testing, you can configure Delta-QA to capture the variants by passing the right cookies/headers.
Conclusion
Next.js is a powerful framework. But that power has a cost in rendering complexity that most teams underestimate. SSR, ISR, App Router, Server Components, streaming, nested layouts: each feature adds a path that can produce an unexpected visual result.
Visual testing is not a luxury for Next.js apps. It is a necessity. And the tool you choose must be able to capture the real result of your application: not isolated components in an artificial environment.
If you build with Next.js and do not yet have a visual testing strategy, you are flying blind. It is time to fix that.