Next.js starter your AI actually understands. Ship internal tools in days not weeks. Pre-order $199 $499 → [Get it now]

How to use Angular Universal for SSR

Server-side rendering improves SEO, initial page load performance, and enables proper social media preview cards for Angular applications. As the creator of CoreUI, a widely used open-source UI library, I’ve implemented SSR in production Angular applications throughout my 11 years of framework development. The most reliable approach is using Angular Universal, which renders your application on the server before sending it to the client. This method provides the benefits of SSR while maintaining the full functionality of your Angular app.

Add Angular Universal to your project using the Angular CLI schematic.

ng add @nguniversal/express-engine

Here the Angular CLI adds all necessary files for server-side rendering including a Node.js Express server configuration. The command modifies your angular.json to include server build targets and creates server.ts for the Express server setup. Build both client and server bundles with npm run build:ssr, then start the server with npm run serve:ssr. The server pre-renders pages on request and serves fully-rendered HTML to clients and search engine crawlers.

Best Practice Note:

This is the approach we recommend for CoreUI Angular applications requiring SEO optimization and improved initial load performance. Always check for platform-specific code using isPlatformBrowser and isPlatformServer to avoid Node.js API usage in browser code, and use TransferState to avoid duplicate HTTP requests between server and client.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to Add a Tab in HTML
How to Add a Tab in HTML

How to Detect a Click Outside of a React Component
How to Detect a Click Outside of a React Component

How to migrate CoreUI React Templates to Vite
How to migrate CoreUI React Templates to Vite

How to sort an array of objects by string property value in JavaScript
How to sort an array of objects by string property value in JavaScript

Answers by CoreUI Core Team