Next.js & App Router (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What are React Server Components (RSC) and how do they differ from Client Components?
junior LevelCLIComponents
In Simple Words: In Next.js App Router, all components are React Server Components by default:
- RSC (Server Components):
- Execute only on the server.
- Can directly query databases (
db.query()), access server files (fs), and use sensitive secrets (process.env.API_SECRET). - Their code and third-party dependencies are NEVER bundled into client JavaScript (0KB client bundle size!).
- Cannot use browser APIs (
window,localStorage) or React hooks (useState,useEffect).
- Client Components (
'use client'):- Rendered on the server during SSR and hydrated in the browser.
- Can use state, effects, event listeners (
onClick), and browser APIs.