Deep Dive•January 5, 2025
React Server Components: A Deep Dive
SN
Shefayet Nayon12 min read
preview_render.png
The Paradigm Shift
React Server Components (RSC) allow you to write UI that can be rendered on the server. This sounds simple, but it fundamentally changes how we build React apps.
The "Waterflow" Problem
In traditional React, we often had network waterfalls.
- App mounts
- Header fetches user
- Dashboard fetches stats
With RSC, we can fetch everything in parallel on the server before sending HTML to the client.
Client Components
Use "use client" at the top of a file to mark it as a Client Component. This is required for:
useStateuseEffect- Event listeners (
onClick)
"use client";
import { useState } from 'react';
export default function Counter() {
const [count, setCount] = useState(0);
return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
}Summary
RSC is not just for performance; it's a better composition model for data-heavy applications.