GoalComplete the picture — from browser to server. Understand Node.js (it's the same V8!), rendering strategies, hydration, and where to run code.
Lessons
Node.js = V8 + different host APIs
Node.js is V8 running outside the browser, with different host APIs:
Browser
Node.js
DOM, fetch, localStorage
fs, http, process
Web Workers
Worker Threads
window
global / globalThis
The same single-threaded Event Loop (Level 3) runs in Node. Blocking the thread server-side is far worse — it blocks ALL requests, not just one user's tab.
Rendering strategies
CSR (Client-Side Rendering) — server sends empty shell + JS bundle. Browser builds everything.
→ Slow first paint, great for SPAs behind login.
SSR (Server-Side Rendering) — server runs React, sends full HTML. JS hydrates it.
→ Fast first paint + SEO. Gap where page is visible but not interactive.
SSG (Static Site Generation) — HTML built at build time, served as static files.
→ Fastest possible. For blogs, docs, marketing.
ISR (Incremental Static Regeneration) — SSG that regenerates pages in the background.
→ Static speed + freshness.
Hydration & the mismatch bug
After SSR, the page is visible but dead (no JS, no handlers). Hydration is React adopting the server HTML and attaching interactivity.
Hydration mismatch: if server HTML ≠ client's first render, React warns and may discard server HTML.
jsx
// ❌ Mismatch — server doesn't know client time
function Clock() {
return <p>{new Date().toLocaleTimeString()}</p>;
}
// ✅ Fix — defer client-only values to after hydration
function Clock() {
const [time, setTime] = useState(null);
useEffect(() => setTime(new Date().toLocaleTimeString()), []);
return <p>{time ?? "..."}</p>;
}
Client is public — secrets live on the server
Everything in your JS bundle is public. The user can read all of it.
❌ API key in a React component → exposed to everyone
✅ API key in a server route / server component → never reaches the browser
This is the most important security rule in fullstack frontend. Secrets, auth validation, and trusted business logic must live on the server. "Hiding" it in client code is not security.
Edge runs server-like code geographically close to the user — for auth checks, redirects, geo-personalization. Low latency, limited Node APIs.
Challenges2
Write working code. Run to see output. Check to grade.
CH1
Pick the rendering strategy
Medium
Log the correct strategy ("csr", "ssr", "ssg", "isr") for each:
(a) Company blog, articles change once a week
(b) Internal admin dashboard, no SEO
(c) E-commerce product page, needs SEO + live stock
(d) News homepage, millions of views, needs freshness
JavaScript
CH2
Security: where does this code belong?
Hard
For each scenario, log "client", "server", or "edge":
(a) Fetching user data from your DB with your DB password
(b) Rendering a user's personalized dashboard (needs their data, has SEO)
(c) Checking if the user's auth token is valid before serving any page
(d) A button that submits a form to an API