My Next.js dev server takes forever to start. How do I figure out what's actually slow?

Slow dev startup in Next.js almost always comes down to one of three things: module count, heavy config work at boot, or something outside the compiler entirely. Here's how to narrow it down fast.

1. Get a baseline

Start the server with profiling on and note the two numbers it prints:

NEXT_TURBOPACK_TRACING=1 next dev
  • Startup time: everything before "Ready". Config loading, env files, plugins.
  • First compile: the time after you hit a route. Module graph size lives here.

2. Check the usual suspects

SymptomLikely cause
Slow before "Ready"Heavy next.config, sync I/O in config, large .env cascade
Slow first pageBarrel files pulling in whole icon or UI libraries
Slow every saveType checking or lint running in the dev loop

The barrel-file one is the classic. A single import { Check } from "lucide-react" through a barrel can pull thousands of modules into the graph. Fix it with:

// next.config.ts
const nextConfig = {
  experimental: {
    optimizePackageImports: ["lucide-react", "@acme/ui"],
  },
}

3. Measure, don't guess

If neither jumps out, generate a trace and look at the actual spans:

next dev
# reproduce the slow start, then:
next internal trace .next/trace

Compare against a bare create-next-app on the same machine first. If that's also slow, the problem is your machine or antivirus scanning node_modules, not your app.

Want to paste the first few lines of your trace output? I can point at the exact span that's eating the time.