Learn how to set up Angular Universal for SEO. Enable server-side rendering (SSR) in Angular to improve crawlability, Core Web Vitals, and search engine rankings.
🔹 Why Angular Universal (SSR) is Crucial for SEO
Angular apps are client-side rendered (CSR) by default, meaning content is built in the browser after JavaScript execution.
The problem? Search engine crawlers may see blank pages if JS doesn’t render properly.
👉 Solution = Server-Side Rendering (SSR) with Angular Universal.
Benefits of Angular Universal for SEO
- ✅ Google & Bing see fully rendered HTML instantly
- ✅ Faster first contentful paint (FCP) → better Core Web Vitals
- ✅ Improved shareability on social media (Open Graph tags render correctly)
- ✅ Works better for slower devices or poor connections
🔹 CSR vs SSR vs Prerendering Recap
Rendering | How it Works | SEO Impact |
---|---|---|
CSR | Browser builds page with JS | Crawlers may miss content |
SSR | Server sends pre-rendered HTML | Best for dynamic content SEO |
Prerendering | HTML generated at build time | Best for static content SEO |
🔹 Step 1: Install Angular Universal
Run this Angular CLI command in your project:
ng add @nguniversal/express-engine
👉 What this does:
- Installs Angular Universal packages
- Adds a server app module
- Configures an Express server
🔹 Step 2: Verify New Files
After installation, you’ll see:
server.ts
→ Express server entry pointapp.server.module.ts
→ Server-side modulemain.server.ts
→ Bootstraps server-side app
🔹 Step 3: Build and Serve SSR App
Build the Universal app:
npm run build:ssr
Serve the app:
npm run serve:ssr
Now visit:
http://localhost:4000
👉 You should see your Angular app pre-rendered on the server.
🔹 Step 4: Check SEO Output
To confirm SSR is working:
- Right-click → View Page Source
- You should see static HTML with content & meta tags (instead of
<app-root></app-root>
only).
👉 This is what search engines will crawl.
🔹 Step 5: Dynamic Meta Tags with SSR
Use Angular’s Meta
and Title
services (from Blog 2).
Example in home.component.ts
:
import { Component, OnInit } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
})
export class HomeComponent implements OnInit {
constructor(private title: Title, private meta: Meta) {}
ngOnInit() {
this.title.setTitle('Home | Angular Universal SEO');
this.meta.updateTag({ name: 'description', content: 'Server-side rendering in Angular improves SEO visibility.' });
}
}
With SSR enabled, these meta tags will render in the HTML source → perfect for SEO.
🔹 Step 6: Deploy Angular Universal App
You can deploy SSR apps to:
- Firebase Hosting + Cloud Functions
- Vercel
- Netlify
- AWS / Azure / GCP
- Custom Node.js servers
👉 Ensure your server handles 301 redirects, caching, and compression for SEO & performance.
🔹 Troubleshooting Common Issues
- ❌ Blank Page? → Check
server.ts
setup. - ❌ Meta tags not showing? → Ensure
Meta
&Title
services are used insidengOnInit
. - ❌ Slow load times? → Enable caching and lazy loading (covered in Blog 7).
🔹 Final Thoughts
Angular Universal makes your Angular app SEO-friendly by default.
In this blog, you learned:
- Why SSR is essential for SEO
- How to install Angular Universal
- How to build, run, and verify SSR
- How to set dynamic meta tags
- Deployment options for SSR apps
👉 In the next blog, we’ll cover Prerendering in Angular—a lightweight alternative to SSR, perfect for static websites.
Share this:
- Click to share on Facebook (Opens in new window) Facebook
- Click to share on X (Opens in new window) X
- Click to share on WhatsApp (Opens in new window) WhatsApp
- Click to email a link to a friend (Opens in new window) Email
- Click to share on Pinterest (Opens in new window) Pinterest
- Click to share on LinkedIn (Opens in new window) LinkedIn
- Click to share on Threads (Opens in new window) Threads
- Click to share on Telegram (Opens in new window) Telegram