Menu

React Server Components vs 'use client': What Actually Ships to the Browser
📰

React Server Components vs 'use client': What Actually Ships to the Browser

DEV Community: react·Mohsen Fallahnejad·3 days ago
#Jbm4Oh3w
#devtoreact#devto#dev#client#server
Reading 0:00
15s threshold

Add a log to a Client Component:

"use client" ;

export function LikeButton ( ) { console . log ( "rendering LikeButton" ) ; // shows up in your terminal too return < button > Like </ button > ; }

Enter fullscreen mode

Exit fullscreen mode

Load the page, and the message appears in the terminal where Next.js runs , not just in the browser console.

So "use client" doesn't mean "runs only in the browser". It means something else, and once you see what, it's clear where to put it.

The mental model: the result vs the result plus the code

Both kinds of component render on the server first, so the browser gets real HTML. The difference is what gets sent along with it:

A Server Component sends only its result . A Client Component sends its result plus the code to run it again in the browser.

The result is enough to look at.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.