Next.js 15 Tutorial - 4 - Before We Start
Understanding React Server Components
Introduction to React Server Components
- The discussion begins with an introduction to a fundamental concept essential for understanding routing in Next.js: React Server Components (RSC).
- RSC is a new architecture introduced by the React team and adopted by Next.js, which divides components into two types: server components and client components.
Key Characteristics of Component Types
Server Components
- By default, Next.js treats all components as server components, which can perform server-side tasks such as reading files or fetching data from databases.
- However, server components cannot use React hooks or handle user interactions.
Client Components
- To create a client component, developers must add the
use clientdirective at the top of their component file.
- While client components cannot perform server-side tasks like reading files, they can utilize hooks and manage user interactions. They resemble traditional React components familiar from earlier versions.
Practical Application in Routing