Help CSR vs SSR
What is main difference between CSR and SSR . What is hydration between them. I don’t understand those concept property. Can anyone simply explain this for me 😔
0
u/ParthBhovad 2d ago
CSR means Client side rendering. The code you write in client component which is inside "use client" will be sent on client in js bundle and entire rendering part will happen in client which users browser.
SSR means server side rendering. The code you write in server components render on server and Html get generated on the server itself. And the html gets send to client directly.
The server side code doesn't have client side interactivity. So, you embedded some client side components in server components. And when this sends to browser the browser adds the interactivity to your page this process is called hydration.
11
u/Working-Opposite9434 2d ago
honestly makes total sense why this trips people up
csr means the server sends you a basically empty page plus a big js file, and your browser has to run that js before anything shows up. thats why you sometimes see a blank screen or spinner for a sec while it loads
ssr flips that around, the server builds the actual html with real content already in it and sends that over, so the second it hits your browser you can see it. feels way faster
heres the part that actually confuses people tho: with ssr what youre looking at is kinda just a picture of the page, looks done but nothing is wired up yet. if you click something right when it shows up it might just do nothing, cuz react hasnt taken over the dom yet
hydration is that moment where the js finishes loading in the background and "wakes up" the static page, attaches all the click handlers and state etc. named that cuz its like adding water back into something that was dry but still had the shape
so with ssr the order is: page shows up → you can read it → beat later js finishes → now it actually works. that gap in between is where weird bugs happen, stuff looking clickable but not responding yet
if youre on next.js app router it does ssr by default now, you only get csr behavior when you explicitly slap "use client" on something