Server-Side Rendering (SSR)
A technique where the initial HTML content is generated on the server for each request rather than in the browser.
- When a user requests a page, the server runs the React components
- The server generates the full HTML content
- Server sends this HTML to the browser displaying the content immediately
- React then “hydrates” the page, attaching event handlers and making it interactive
Advantages:
- Faster initial page load
- Better SEO, search engines can crawl the fully rendered content
Static Site Generation (SSG)
A technique where the HTML pages are generated at build time, rather than on each request or on the client side.
Great for content that doesn’t change frequently
Fastest loading experience for users.
Client-side Rendering (CSR):
- Initial HTML is minimal, and content is populated by JavaScript in the browser
- Slower initial load, but faster subsequent navigation
- May have SEO challenges if not implemented carefully
- More dynamic, can easily update content without a full page reload