React Server Components (RSC) are a new type of React component that render on the server, not in the browser. They enable you to build parts of your application that run ahead of time or per request, reducing the load on the client-side.
async function Page({page}) {
const content = await file.readFile(`${page}.md`);
return <div>{sanitizeHtml(marked(content))}</div>;
}
In this example, the server component Page
reads markdown content from the server and renders it as HTML. This reduces the work that needs to be done on the client.
async/await
natively for data-fetching.Suspense
to stream partial content as data loads.React Server Components allow developers to shift data-fetching and heavy logic to the server, leaving the client responsible only for interactivity. This results in faster apps, leaner bundles, and a better user experience overall.