React Server Components (RSC) run on the server and send rendered HTML to the client. They reduce client-side JavaScript and improve initial page load.
Server vs Client Components
Server Components render on the server, have no client-side JavaScript, and can directly access backend resources. Client Components are traditional React components that run in the browser.
Benefits
Zero bundle size for server components, direct database/API access, improved initial load time, and automatic code splitting.
When to Use Each
Use Server Components for static content, data fetching, and accessing backend resources. Use Client Components for interactivity, hooks, browser APIs, and event handlers.
The "use client" Directive
Mark a component as a Client Component by adding "use client" at the top of the file. Everything it imports becomes part of the client bundle.
Data Fetching
Server Components can be async and fetch data directly. No need for useEffect or client-side data fetching libraries.