Since the libraries are responsible for turning components into HTML, it is up to the framework to determine where this conversion happens. In other words: where the HTML is generated before being served to the client. This is where rendering modes come into play.

You can generate the HTML on the server, which we call Server Side Rendering (SSR), or on the client, which we call Client Side Rendering (CSR). In both, the request always reaches a server. What changes is the content of the response. In SSR, the response contains the HTML ready, with the data in it, generated on the fly. In CSR, the server returns only the bare minimum HTML needed for the page to load, plus the JavaScript the browser needs to run, but no data. The data arrives in stages, which is why the experience feels different to the user: the page fills in piece by piece.

Some techniques help mitigate this in CSR, such as prefetching, caching and rendering skeletons.

NOTE

This is why client and server communication is an important concept to understand.

Choosing between them

The most important criterion for choosing between SSR and CSR is whether the data needs to be present in the first response. For example, if SEO (Search Engine Optimization) is important, SSR is the better solution, since it gives you all the data upfront. On the other hand, if users stay in the app for long sessions, interact heavily (e.g. dashboards), and there’s no need for SEO (e.g. everything is behind a login), an SPA (Single Page Application, which uses CSR) is a good fit, since the first-load cost (which can be slow) is paid once and navigation afterward is fast.

When it comes to authentication, both can handle it safely, with some implementation differences. If your application needs SSO or some integration with identity providers (IdPs like Entra), it doesn’t really matter which one you choose.

NOTE

Static Site Generation (SSG) gives the same benefits for SEO, or when you need the content upfront, if the content rarely changes. So SSR is the better choice when the content changes per request or per user, or too often to prebuild.

Hydration

Hydration is a topic under SSR (and SSG) that I need to understand a bit better, because it is still confusing to me.