A Next.js app can be very fast or surprisingly slow under load, and the difference is mostly how each page is rendered. A static page served from a CDN can take almost any traffic. A server-rendered page that calls three APIs on every request cannot. This guide covers what to test in a Next.js app, what to skip, and where the bottlenecks usually are.
Know how each route is rendered
Before you write a test, list your important routes and how each one renders:
- Static (built at build time): HTML served from the CDN. Very cheap.
- ISR (incremental static regeneration): static, but regenerated in the background after a revalidate period. Cheap most of the time, with occasional regeneration work.
- SSR / dynamic: rendered on the server for every request. With the App Router, using
cookies(),headers()or uncachedfetchmakes a route dynamic. - API routes and route handlers: server code, every request.
- Server actions: POST requests to your server, every time.
The next build output marks which routes are static and which are dynamic. Start there.
Test the server, not the CDN
Loading /_next/static/... JavaScript and CSS or a fully static page mostly tests your CDN. That is usually fine, and it is someone else's capacity. Focus the test on what runs your code:
- SSR pages, especially personalised ones (dashboard, account, cart);
- API routes and route handlers;
- server actions such as add to cart or submit form;
- ISR pages right after a deploy, when caches are empty.
Run against a production build (next build and next start, or your real hosting). next dev compiles on demand and tells you nothing about production speed.
Check cache headers
Look at the response headers of every route you test:
Cache-Controlon SSR pages is oftenprivate, no-cache, no-store, so every request reaches your server.- ISR pages use
s-maxageandstale-while-revalidate. Check the CDN really caches them. - A cookie read or a
no-storefetch in a shared layout can make every page under it dynamic.
If a page you expected to be static is rendering on every request, fixing that may be worth more than any server tuning.
Edge vs Node runtime
Routes can run on the Node.js runtime or the Edge runtime. Edge functions start fast and run close to users, but they still have to call your database or API, which often sits in one region. A fast edge function waiting 150 ms for a database on another continent is not fast. When you compare the two, test from the regions your users are in (load testing from multiple regions).
If you self-host on Node, remember that one Node process runs on one CPU core. Run several (with a process manager or containers) to use the whole machine.
The usual bottleneck is upstream
In most Next.js apps, rendering is not what slows down. The upstream calls are: your own backend API, a headless CMS, a database, a search or auth provider. Under load:
- an SSR page that makes 4 sequential fetches is as slow as all 4 added together. Run them in parallel where you can;
- a CMS or third-party API may have rate limits far below your traffic;
- the same data fetched by many components on one request should be deduplicated or cached;
- database connections from serverless functions add up fast, so use a pooler.
Measure the upstream services directly too. If the API behind the page is slow on its own, see find the bottleneck in a slow API.
Read the results per step
Look at each route separately. If the product page stays flat but the cart page climbs, look at what the cart page fetches. Compare p95 per step with a baseline run, and re-run the same test after each change.
Next.js with Hoofbeat
Describe the journey in HoofbeatChat ("open a product page, add to cart through the API, then load the cart page"), or import a HAR recording and remove the static asset requests so the test focuses on your server (how). Put most of the load on HTTP users that hit your pages and API routes, and add a few real-browser users (headless Chromium, with web vitals like LCP) to see what visitors feel under that load. Capture auth tokens or cookies from the sign-in step, and add a trace header so the slowest requests link to Jaeger or Tempo, where you can see which upstream call took the time.