Lesson 171 of 1596
React Server Components
RSCs render on the server and stream HTML to the client. Zero-JS components, free data fetching. Learn the boundary rules.
Creators · AI-Assisted Coding · ~27 min read
Two Worlds, One Tree
Server Components fetch data and render HTML on the server. Client Components add interactivity. They can nest — a server component can import a client component as a child.
Fetching directly in the component. No loading state, no useEffect. Server does the work.
// app/feed/page.tsx — Server Component (no directive) import LikeButton from "./LikeButton"; async function getFeed() { const r = await fetch("https://api.example.com/feed", { cache: "no-store", }); if (!r.ok) throw new Error("feed failed"); return r.json() as Promise<{ id: string; text: string }[]>; } export default async function FeedPage() { const posts = await getFeed(); return ( <ul> {posts.map((p) => ( <li key={p.id}> {p.text} <LikeButton postId={p.id} /> </li> ))} </ul> ); }`use client` at the top opts in to state and event handlers. Props still flow in from the server.
// app/feed/LikeButton.tsx — Client Component "use client"; import { useState } from "react"; export default function LikeButton({ postId }: { postId: string }) { const [liked, setLiked] = useState(false); return ( <button onClick={() => setLiked((v) => !v)}> {liked ? "♥" : "♡"} </button> ); }Key terms in this lesson
The big idea: fetch on the server, interact on the client, and respect the serialization boundary. Most components should stay on the server.
End-of-lesson quiz
Check what stuck
6 questions · Score saves to your progress.
Tutor
Curious about “React Server Components”?
Ask anything about this lesson. I’ll answer using just what you’re reading — short, friendly, grounded.
Progress saved locally in this browser. Sign in to sync across devices.
Related lessons
Keep going
Creators · 45 min
Calling the Claude API With Streaming
Anthropic's SDK in 20 lines. Learn messages, streaming tokens, and basic error handling.
Creators · 40 min
Calling the OpenAI API
The Responses API is OpenAI's modern surface. One call, text and tools. Learn the shape you'll use most.
Creators · 50 min
Deploying an AI App to Vercel
Streaming AI chat to production takes one framework and three env vars. Learn the deploy path that actually ships.
