From the course: Angular Performance Optimization Techniques
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Server-side rendering in action - Angular Tutorial
From the course: Angular Performance Optimization Techniques
Server-side rendering in action
- [Instructor] So now let's set up our project for server-side rendering and see what command are needed. So if you start from scratch with a brand new Angular project, the CLI will automatically ask you if you want to adds server-side rendering. You can also specify this directly in your command when creating a new project, ng new --ssr. Now, if you want to add server-side rendering to an existing project after upgrading it to at least version 17, which is when server-side rendering became stable in Angular, you can do ng add @angular/ssr. So let's run that command in our project, ng add @angular/ssr. So the command is doing quite a few different things. It's creating some server-side code now, changing the Angular config, Angular JSON, the TypeScript config, and the application config as well. So if we go to our project, we can see that now we have a main.server.ts, server.ts. So this is the code that Angular automatically generated for us that's going to run the server-side…