The Forensics Of React Server Components (RSCs)<\/h1>\nLazar Nikolov<\/address>\n 2024-05-09T13:00:00+00:00
\n 2024-08-30T10:05:08+00:00
\n <\/header>\n
This article is sponsored by Sentry.io<\/b><\/p>\n
In this article, we\u2019re going to look deeply at React Server Components (RSCs). They are the latest innovation in React\u2019s ecosystem, leveraging both server-side and client-side rendering as well as streaming HTML<\/a> to deliver content as fast as possible.<\/p>\nWe will get really nerdy to get a full understanding of how RFCs fit into the React picture, the level of control they offer over the rendering lifecycle of components, and what page loads look like with RFCs in place.<\/p>\n
But before we dive into all of that, I think it\u2019s worth looking back at how React has rendered websites up until this point to set the context for why we need RFCs in the first place.<\/p>\n
The Early Days: React Client-Side Rendering<\/h2>\n
The first React apps were rendered on the client side, i.e., in the browser. As developers, we wrote apps with JavaScript classes as components and packaged everything up using bundlers, like Webpack, in a nicely compiled and tree-shaken heap of code ready to ship in a production environment.<\/p>\n
The HTML that returned from the server contained a few things, including:<\/p>\n
\n- An HTML document with metadata in the
<head><\/code> and a blank <div><\/code> in the <body><\/code> used as a hook to inject the app into the DOM;<\/li>\n- JavaScript resources containing React\u2019s core code and the actual code for the web app, which would generate the user interface and populate the app inside of the empty
<div><\/code>.<\/li>\n<\/ul>\n
\n 2024-08-30T10:05:08+00:00
\n <\/header>\n
We will get really nerdy to get a full understanding of how RFCs fit into the React picture, the level of control they offer over the rendering lifecycle of components, and what page loads look like with RFCs in place.<\/p>\n
But before we dive into all of that, I think it\u2019s worth looking back at how React has rendered websites up until this point to set the context for why we need RFCs in the first place.<\/p>\n
The Early Days: React Client-Side Rendering<\/h2>\n
The first React apps were rendered on the client side, i.e., in the browser. As developers, we wrote apps with JavaScript classes as components and packaged everything up using bundlers, like Webpack, in a nicely compiled and tree-shaken heap of code ready to ship in a production environment.<\/p>\n
The HTML that returned from the server contained a few things, including:<\/p>\n
- \n
- An HTML document with metadata in the
<head><\/code> and a blank
<div><\/code> in the
<body><\/code> used as a hook to inject the app into the DOM;<\/li>\n
- JavaScript resources containing React\u2019s core code and the actual code for the web app, which would generate the user interface and populate the app inside of the empty
<div><\/code>.<\/li>\n<\/ul>\n
- JavaScript resources containing React\u2019s core code and the actual code for the web app, which would generate the user interface and populate the app inside of the empty