avatarNavneet Singh


Building a Hybrid Rendering App with Angular 17 and esbuild

Hybrid rendering is a technique that combines server-side rendering (SSR) and client-side rendering (CSR) to deliver a fast, efficient, and interactive user experience. In this article, we will explore how to build a hybrid rendering application using Angular 17 and esbuild.

Server-Side Rendering (SSR): In SSR, the server processes the initial request, generates the full HTML for the page, and sends it back to the client. This allows the page to be visible and usable almost immediately, which is particularly beneficial for users with slow internet connections or less powerful devices.

Client-Side Rendering (CSR): Once the initial page is loaded on the client side, Angular takes over and handles any subsequent navigation and updates on the client side. This means that the server doesn’t need to generate a new HTML page for every request, which can significantly improve performance for complex applications.

By combining SSR and CSR, hybrid rendering allows you to leverage the benefits of both techniques. The server-side rendering ensures that your application is quickly visible and indexable by search engines, while the client-side rendering allows for fast, smooth updates once the initial page has loaded.


Before we start, make sure you have the following installed on your system:

  • Node.js and npm
  • Angular CLI

Step 1: Setting up the Angular Project

First, we need to create a new Angular project. Open your terminal and run the following command:

ng new hybrid-app

Step 2: Installing esbuild

Next, we install esbuild, a super-fast JavaScript bundler and minifier. Run the following command in your project directory:

npm install esbuild

Step 3: Configuring Angular for SSR

To configure Angular for SSR, we need to add Angular Universal to our project. Run the following command:

ng add @nguniversal/express-engine

Step 4: Configuring esbuild

Create a build.js file in the root of your project and add the following code:

const esbuild = require('esbuild');
// More code to come...

Step 5: Building the App

Finally, we can build our app. First, build the client-side bundle:

ng build --prod

Then, build the server-side bundle with esbuild:

node build.js


And there you have it! You’ve just built a hybrid rendering app with Angular 17 and esbuild. This setup allows you to enjoy the benefits of both server-side and client-side rendering, providing a fast and interactive experience for your users.

Remember, this is a basic setup and might need to be adjusted based on the needs of your specific project. Happy coding!

If you enjoyed this article, consider trying out the AI service I recommend. It provides the same performance and functions to ChatGPT Plus(GPT-4) but more cost-effective, at just $6/month (Special offer for $1/month). Click here to try ZAI.chat.

Angular 17
Hybrid Rendering
Front End Development
Recommended from ReadMedium