The Quickest Way to Debug Server Component Boundaries
How to trace exactly where your Next.js application switches from Server to Client.
In Next.js, it's easy to accidentally make a huge chunk of your app a Client Component by placing a "use client" directive too high in the tree.
The Debugging Trick:
Add console.log("Rendering Component X") in the body of your components.
- If it prints in your terminal, it rendered on the server.
- If it prints in your browser console, it hydrated on the client.
- If it prints in both, it's a Client Component that was SSR'd.
To ensure a component NEVER renders on the client, import the server-only package:
import 'server-only';
If any Client Component tries to import it, the build will hard fail.
Tags
Related Blogs
Debugging SSR Runtime Crashes on Vercel: Node vs Edge
When your Next.js app works perfectly on localhost but throws 500s on Vercel. A deep dive into Node runtimes, the Edge network, and how to debug elusive server-side crashes.
Fixing Hydration Errors in Next.js: A Structural Approach
Hydration errors are the bane of Next.js developers. Stop fighting the warnings and learn the structural causes behind 'Text content did not match server-rendered HTML'.
Migrating from TanStack Start to Next.js App Router: An Architecture Post-Mortem
A deep dive into why we moved our entire CMS away from Vite SSR and TanStack Router, the performance implications of Server Components, and the hydration traps we had to fix.