Hi, I am Sanjeet Tiwari...
Let's talk about

Back to Notes

Rendering Patterns

Web React

Introductions

There are many ways a website can be rendered depending on the underlying use case. A website is ultimately a combination of HTML (view), CSS (styles) and JS (interactivity).

First, we need to know what is Hydration

Hydration is attaching event listeners to the HTML elements in the page, that is done by the browser which is prescribed in the JS code.

Static Rendering

In this type,

Static Rendering

Even this type of rendering has got several variations.

Plain Static Rendering

In this type,

This is suitable for websites which are,

Plain Static Rendering

In terms of performance measures,

Static Rendering with Client-side fetch

In this type,

This is suitable for websites which,

Static Rendering with Fetch

In terms of performance measures,

Static rendering with getStaticProps

In this type,

This is suitable for websites which,

Static Rendering with Static Props

In terms of performance measures,

Incremental Static Regeneration

In this type,

This is suitable for websites which,

Incremental Static Regeneration

In terms of performance measures,

On-demand Incremental Static Regeneration

This type is nothing but Incremental Static Regeneration without the automatic revalidation interval.

Pages will get pre-rendered on-demand, and will rely on revalidate requests, as an example, when API tells whether data was updated or not.

We are eliminating the unnecessary pre-rendering pages even when the data has not updated, and hence, is cheaper.

On Demand Incremental Static Regeneration

Server Side Rendering

In this type,

This is suitable for websites which are,

Server Side Rendering

SSR can be further optimized by using Cache-Control on API calls made to obtain the data.

In terms of performance measures,

Streaming SSR + React Server Components

One thing we can do is combine the advantages of static as well as server side rendering for the same page.

It might happen that there can be certain parts of the page which require user-specific highly dynamic data for which SSR can be used, and for the rest of the page, Static rendering can be used.

React Server components can be used for such components, which will rebuilt on demand on the server.

Streaming Server Side Rendering

Client Side Rendering

In this type,

This is suitable for websites which are -

Comparison

Comparison between all these techniques roughly looks like this -

Comparison of different rendering patterns

Video Source

Advanced Rendering Patterns: Lydia Hallie

Advanced Rendering Patterns: Lydia Hallie

Real World React

WTF do these even mean

WTF do these even mean

Web Dev Simplified

Last updated on 20-07-2024