Course contentsShow
← React
Lesson 1550 of 2,39638. Server Components FundamentalsFree lesson

Visualizing the Tree: Which Parts Ship JavaScript

Mental model for drawing a component tree and identifying which subtrees become JS bundles vs server-only execution.

Visualizing the Tree: Which Parts Ship JavaScript

What you'll learn: How to mentally map your component tree to identify which subtrees become JavaScript bundles vs. stay server-only.

The Mental Model: Painting the Tree

Imagine your component tree as a blueprint where you need to mark which rooms need electricity (JavaScript). Start at the root—it's a Server Component by default. As you traverse down, everything remains "server-only" until you hit a 'use client' boundary.

When you encounter that boundary, mentally draw a box around that Client Component and everything below it. This entire subtree ships to the browser as a JavaScript bundle. It doesn't matter if child components don't use hooks or events—once they're inside a Client Component, they're bundled.

The Exception: Server Components as Props

Here's where it gets interesting: if you pass a Server Component as a prop (like children) to a Client Component, that Server Component breaks out of the box. It stays on the server because the Client Component doesn't import it—it just receives rendered output.

ServerRoot
├── ServerDataFetcher
└── ClientInteractive ('use client' — BOX STARTS)
    ├── ClientButton (inside box, ships JS)
    └── {children} → ServerList (OUTSIDE box, server-only)

Practical Visualization

Walk through your tree asking: "Does this component or any ancestor have 'use client'?" If yes, it ships JavaScript. If no, it's server-only. The exception is when Server Components are passed as props—trace the import path, not just the render tree.

Key Takeaway: Draw boxes at every 'use client' boundary—everything imported within ships as JavaScript, but Server Components passed as props escape the box and stay on the server.