React Server Components
React Server Components (RSC) are a feature of the React library that enable components to render on the server before being sent to the client. These components run in a server environment separate from the client application or SSR server, allowing them to access server-only resources such as filesystems or databases without including that code in the client bundle. The rendered output is streamed to the client as JSON UI descriptions, which the client merges with interactive Client Components without re-rendering or hydrating the server-rendered HTML. Server Components are the default in React, while Client Components require a "use client" directive to handle interactivity using hooks like useState. This architecture reduces the amount of JavaScript sent to the browser by excluding server-only code and enables asynchronous data fetching during rendering. React Server Components also preserve client state, focus, and animations when updated by merging new server props into existing Client Components.
React Server Components allow server-side rendering of React components with direct access to server resources, reducing client bundle size and improving data fetching efficiency.
Reducing Client Bundle Size
By rendering components on the server and excluding server-only code from client bundles, applications can reduce the amount of JavaScript sent to browsers.
Direct Server Data Fetching
Fetching data such as files or database content directly during server-side rendering without additional client-server round trips.
Building Hybrid React Applications
Composing Server Components with Client Components to balance server rendering and client interactivity.
npx create-next-app@latest.