React Server Components (RSC)
Definition
React Server Components (RSCs) allow you to render components strictly on the server. They never ship JavaScript to the client. This reduces bundle sizes, improves SEO, and allows components to directly access backend resources like databases.
Explain Like I'm New
Normally, you send a recipe (JavaScript) to the user's browser, and their browser has to bake the cake (render the component). With Server Components, you bake the cake on your own server, and just ship the finished slice of cake (HTML/UI) to the user. Their browser does zero work.
Real World Example
In Next.js 13+ App Router, components are Server Components by default. If you need a `BlogPost` component, you can literally write `const data = await db.query('SELECT...')` directly inside the component! No APIs, no `useEffect`, no `useState`.
Common Use Cases
- •Accessing backend infrastructure (Databases, File Systems) securely
- •Keeping heavy NPM packages off the client bundle (e.g., Markdown parsers)
- •Improving Initial Page Load speeds and SEO
Interactive Example
Interview Questions
basic
- What is the difference between a Server Component and a Client Component?
- How do you tell React that a component should be a Client Component?
intermediate
- Can you use `useState` or `useEffect` in a Server Component?
- What is the difference between Server-Side Rendering (SSR) and React Server Components (RSC)?
advanced
- Can you import a Server Component inside a Client Component?
- How are Server Components streamed to the browser?
trick
- If an `onClick` event is inside a Server Component, what happens?