What is server-side rendering (SSR), and why would you use it?
Model answer
With SSR, a Node server renders the Angular app to HTML for the first request, so the browser and search engines receive real content immediately, and then Angular takes over in the browser (hydration). Benefits: faster first paint, better SEO and sharing previews. Costs: a server to run, more complexity, and code must not use browser-only objects such as window or localStorage on the server without checks.
Pages behind a login usually do not need SSR. Public content pages do.
Tips
- Mention that you guard browser-only code.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.
More questions
- Why is track important in @for (or trackBy in *ngFor)?
- What are the main ways to improve Angular app performance?
- Why is calling a method in a template expression a performance problem?
- What is NgOptimizedImage and what does it give you?
- What is hydration in Angular?
- What is the difference between SSR, SSG (prerendering) and CSR, and how do you choose?