App Router & RSC · 10 min read · Intermediate
Server Components vs 'use client' Boundaries
Understand why components in app/ are Server Components by default and where to place 'use client' leaves.
What you'll learn
- Keep data fetching and secrets inside Server Components with zero client JS cost
- Add 'use client' only at interactive leaves that need hooks or browser events
- Pass Server Components as children props into Client Components cleanly
Overview
Understand why components in app/ are Server Components by default and where to place ‘use client’ leaves.
Next.js App Router unifies server rendering, streaming, type-safe mutations, and edge-ready caching inside a single React + TypeScript codebase.
Production Code Example
// app/courses/LikeButton.tsx
'use client';
import { useState } from 'react';
export function LikeButton({ initial }: { initial: number }) {
const [likes, setLikes] = useState(initial);
return <button onClick={() => setLikes((n) => n + 1)}>Likes: {likes}</button>;
}
Key Takeaways
- Keep data fetching and secrets inside Server Components with zero client JS cost
- Add ‘use client’ only at interactive leaves that need hooks or browser events
- Pass Server Components as children props into Client Components cleanly
Quick Check
Check Your Understanding
Score: 0 / 1
1. Why should you push `'use client'` as far down the component tree (to interactive leaves) as possible?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.