Angular Server Side Render (SSR)

Created: Jan 18, 2024
Author: Shawn Nolan

There's a lot of talk about how "angular is not SEO friendly", or has "slower performance" than other frameworks. Well let me introduce you to Angular Server-side rendering (SSR)

Enabling SSR

Keep in mind you'll need a server that can run nodejs

It's really easy to enable SSR in Angular in a new project just simply run

ng new --ssr

To add it to an existing project run

ng add @angular/ssr

This will add a couple files to your project, for example "server.ts" in the root directory. This file is where the magic happens, and uses express which nodejs can then fire off your app server side. Having this will help with things like performance to SEO.

If you want the server to always be running in the background, I would suggest using something like pm2

Find more on Angular Server-side rendering (SSR)