← Next.js learning pathNext.js · Module 3 of 10
Server and Client Components
Choose where each component runs for speed and interactivity.
📖 Key ideas
- Components in app/ are Server Components by default.
- Server Components can fetch data directly and ship no JS.
- Add "use client" at the top for state, effects and event handlers.
- Keep client components small, at the leaves of the tree.
- Never import server-only secrets into client components.
💡 Real-life example: Server Components are meals cooked in the kitchen; Client Components are the table-side flambé that needs action in the room.
Server ComponentRuns on the server, no client JS
"use client"Marks a client component
HydrationMaking server HTML interactive in the browser
server-onlyPackage that blocks client imports