Menu

Debugging and Developer Tools

Lesson 5: Debugging and Developer Tools

Where do you look when something breaks?

Symptom Where to look
Error overlay in the browser during dev The overlay's stack trace and source link
console.log from a Server Component does not appear in the browser The terminal running next dev
Hydration mismatch warning Values that differ between server and client (dates, random IDs, window checks)
Page unexpectedly dynamic or static Build output symbols; Next.js DevTools route info
Stale data Cache settings; run with NEXT_PRIVATE_DEBUG_CACHE=1 for cache logs
Slow navigation Next.js DevTools Instant Insights and Navigation Inspector (16.3+)

Example: breakpoints in server code

# Start the dev server with the Node.js inspector
npm run dev -- --inspect

Open chrome://inspect in Chrome, attach to the Next.js process, and set breakpoints in Server Components, Server Actions, and Route Handlers. VS Code users can use a "Next.js: debug full stack" launch configuration.

How it works

  • Next.js DevTools (the floating indicator in dev) shows route information, errors, and, from 16.3, insights into navigations that are not instant.
  • Request logs in Next.js 16 show where time is spent: compile versus render.
  • AI-assisted debugging: the Next.js DevTools MCP server gives coding agents access to routes, logs, and errors. Since 16.3, next dev also maintains an AGENTS.md block pointing agents to documentation that matches your installed version.
  • Production: use structured logs, error tracking, and instrumentation.ts (Module 11) to capture errors that never appear locally.

Common mistakes

Mistake Effect Fix
Looking for server logs in the browser console "My log never runs" Check the terminal (or host logs in production)
Rendering new Date() or Math.random() directly Hydration mismatch Generate on the server and pass as props, or render in an effect
Debugging only in dev Caching and minification issues missed Reproduce with next build && next start
Deleting .next as the first fix for everything Hides the real cause Read the error first; clear the cache only for stale build issues

Key takeaways

  • Server logs live in the terminal; client logs live in the browser.
  • Use the inspector for breakpoints and DevTools insights for routing and navigation problems.

Try it: Add a breakpoint inside a Server Action using --inspect, submit the form, and step through the code.


Nextjs Tutorial

J

Jebasta





Get in Touch For Details