Deploying an Angular App
Build and deploy an Angular application to static hosting, and understand SSR deployment with Angular Universal.
Building for Production
ng build# Outputs optimized static files to dist/my-app/browserFor a plain, client-rendered Angular app, this produces a folder of static HTML, CSS, and JavaScript — no server-side runtime is required to serve it.
Deploying a Static SPA
Any static host works: Netlify, Vercel, Firebase Hosting, or a plain CDN/S3 bucket. Firebase Hosting is a particularly common choice in the Angular ecosystem, with first-class Angular CLI integration (ng deploy).
Firebase Hosting
ng add @angular/fire, then ng deploy — Google's own hosting, closely integrated with the CLI.
Netlify / Vercel
Connect a Git repo; both auto-detect Angular and deploy on every push.
A CDN / Object Storage
Upload the dist/ folder directly to S3, Cloudflare Pages, or similar.
The SPA Routing Gotcha
With client-side routing, directly visiting a deep URL like /about sends that request to the server, which knows nothing about the Angular Router's in-app paths — you must configure the host to redirect all unmatched requests to index.html, letting the Angular Router take over from there.
# public/_redirects (Netlify example)/* /index.html 200Deploying with Angular Universal (SSR)
An SSR-enabled Angular app needs an actual Node.js server (or a serverless/edge platform that supports one) to render pages per request, unlike a plain static SPA.
| Platform | Notes |
|---|---|
| A Node.js server | node dist/my-app/server/server.mjs, for full control over hosting. |
| Firebase Hosting + Cloud Functions | Officially supported for deploying an SSR-enabled Angular app. |
| Vercel / Netlify | Both support deploying Angular Universal apps as serverless functions. |
A Pre-Deployment Checklist
- Run ng build locally and fix any errors or warnings.
- Confirm environment.prod.ts has the correct production values.
- Configure SPA fallback routing if deploying to static hosting.
- Test the production build locally (e.g. with a simple static server) before deploying.
FAQs
No — a client-rendered Angular app builds to static files and can be served from any static host or CDN, with no Node.js runtime needed in production.
By default it targets Firebase (via @angular/fire), but other platforms provide their own ng add-based deploy builders that integrate with the same CLI command.
Summary
A plain Angular SPA deploys as static files to any host, while Angular Universal SSR needs a Node.js-capable platform — both are well-supported across major hosting providers. In the final lesson, you'll review best practices and common mistakes that tie this whole course together.