Web Rendering: What Is SSR, CSR, SSG, and ISR?
Tags: ssr, csr, ssg, isr
Published: 2023-01-20 00:18:59

---
title: Web Rendering: What Is SSR, CSR, SSG, and ISR?
published: true
date: 2022-09-14 03:21:05 UTC
tags: 
- SSR
- CSR
- SSG
- ISR
canonical_url: https://fajarwz.com/blog/web-rendering-what-is-ssr-csr-ssg-and-isr/
---

![Web layout illustration](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdhzhxkf8qg9lfief55u.png)

Web development can sometimes seem complex because there are so many terms to understand. However, these technologies were developed for our benefit. In the past, web development was as simple as using a backend language like [PHP](php.net) to calculate logic on a server, attach data to HTML, and serve it to clients. Today, there are many approaches or design patterns we can try for our apps to make them more efficient. Here are some rendering patterns:

## SSR (Server-Side Rendering)
Server-side rendering (SSR) is a rendering pattern that can be used when developing a web or web app.

![SSR](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zf4m2urs3s5xtertzjo5.jpg)

In this pattern, the pages are rendered at runtime. To implement SSR, we can use a backend technology that can render HTML, such as PHP or a framework like **[Laravel](https://laravel.com)** or **[CodeIgniter](https://codeigniter.com)**, to process a client request. The data is attached to HTML and rendered on the server, then served to the client.

Apps using JavaScript frameworks such as [Vue.js](https://vuejs.org/) and [Angular](https://angular.io/) and libraries like [React](https://reactjs.org/) are typically built using the client-side rendering (CSR) pattern. If you need SSR for your app using these technologies, frameworks such as [Next.js](https://nextjs.org/) or [NuxtJS](https://nuxtjs.org/) are often suggested. If you are using Angular, you can use [Angular Universal](https://angular.io/guide/universal).

Apps using SSR can work without JavaScript enabled on the client's browser.

## CSR (Client-Side Rendering)
This is a common pattern when building a front-end app with JavaScript technologies such as **React, Vue.js or Angular**. They support client-side rendering (CSR) out of the box.

![CSR](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7ocjvh39y60g90057w1.jpg)

The pages are **rendered at runtime**, on the **client-side**. When a user visits a page on the site for the first time, the browser must wait for the entire JavaScript bundle to be downloaded and executed on the client-side. This makes the app slow to load initially, but subsequent page loads are fast. The slow first page load is not good for search engine optimization (SEO).

Apps using CSR require JavaScript to be enabled on the client's browser.

> **Read also:**
> * [Create Login With Google OAuth Using Laravel Socialite](https://fajarwz.com/blog/create-login-with-google-oauth-using-laravel-socialite/)
> * [Laravel Rest API Authentication Using JWT Tutorial](https://fajarwz.com/blog/laravel-rest-api-authentication-using-jwt-tutorial/)
> * [Laravel Api Documentation Generator With OpenAPI/Swagger Using DarkaOnLine/L5-Swagger](https://fajarwz.com/blog/laravel-api-documentation-generator-with-open-api-swagger-using-darkaonline-l5-swagger/)

## SSG (Static Site Generation)
A web app that uses this pattern serves **static pages**.

![SSG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pj8bev8oeuwkpx71m0le.jpg)

Pages on a static site generator (SSG) site are **rendered at build-time**. When the app is deployed, it builds the entire site as a static site. When a request comes in, the user receives a static page, making the site very fast.

However, when a page is added or changed, the app must rebuild all pages. If you have 10,000 pages, it will rebuild all 10,000 pages for a small change made on a single page.

**[Hugo](https://gohugo.io/), [Gatsby](https://www.gatsbyjs.com/), [Jekyll](https://jekyllrb.com/)**, are popular technologies that can help us implement SSG.

This site (fajarwz.com) is also built with SSG. I also made the template, [Mayhugo](https://github.com/fajarwz/mayhugo), open source at [Github](https://github.com/fajarwz/mayhugo).

**[Next.js](https://nextjs.org/docs/basic-features/data-fetching/get-static-props) and [NuxtJS](https://nuxtjs.org/docs/concepts/static-site-generation/)** also support SSG.

Apps using SSG work without JavaScript enabled on the client's browser.

## ISR (Incremental Static Regeneration)
This is like a static site generator (SSG) site, except when something changes, we don't need to rebuild the entire site. Static generation is done on a per-page basis.

![ISR](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4rmc070isv47o4vflw70.jpg)

**[Next.js support ISR](https://nextjs.org/docs/basic-features/data-fetching/incremental-static-regeneration)**. It offers at least two ways to regenerate page changes:

1. Page is revalidated **at a set time interval**. An example can be found [here](https://reactions-demo.vercel.app/)
2. Page is revalidated **on demand**. You can see a demo [here](https://on-demand-isr.vercel.app/)

Apps using ISR work without JavaScript enabled on the client's browser.

## Conclusions
That's it. SSR is good for a site that needs SEO and speed is very important. CSR is good when you only develop an internal app or don't need SEO. SSG is good if we have an app that doesn't change frequently, such as a blog, company profile, or portfolio website. ISR is for an app that is like an SSG app but may have millions of pages.

## Read Also
- [Send SMS From Laravel App Using Vonage](https://fajarwz.com/blog/send-sms-from-laravel-app-using-vonage/)
- [Send Slack Notifications From Laravel App](https://fajarwz.com/blog/send-slack-notifications-from-laravel-app/)
- [Create Reusable Query With Laravel Query Scope](https://fajarwz.com/blog/create-reusable-query-with-laravel-query-scope/)