Client-Side Rendering (CSR)
Explore Client-Side Rendering (CSR) in Next.js to understand how it allows dynamic rendering in the browser, improving user experience with native app-like performance, smoother transitions, and less server workload. Learn techniques like using React hooks, dynamic imports, and managing browser-only APIs to build scalable web applications without SSR.
A standard React app is rendered once the JavaScript bundle has been transferred from the server to the client. If we’re familiar with
As we can see, we can only find one div inside the body tag: <div id="root"></div>. During the build phase, create-react-app will inject the compiled JavaScript and CSS files into this HTML page and use the root div as a target container for rendering the whole application.
That means that once we publish this page to any hosting provider (Vercel, Netlify, Google Cloud, AWS, etc.), the first time we call the desired URL, our browser will first render the preceding HTML. Then, following the script and link tags contained in the preceding markup (injected by CRA at build time), the browser will render the whole application, making it available for any sort of interaction.
Advantages of CSR
The main advantages of CSR are:
It makes our app feel like a ...