A Server-Side Rendering (SSR) starter project built with Angular 21 and the Nebular UI Theme. Based on the Angular Tour of Heroes tutorial, extended with SSR and a beautiful Nebular component library.
- ⚡ Angular 21 — Latest Angular with full SSR support
- 🎨 Nebular Theme 17 — Rich UI component library with theming
- 🖥️ Angular Universal (SSR) — Server-side rendering via
@angular/ssrand Express - 🦸 Tour of Heroes — Angular's iconic tutorial app as a demo
- 🔁 Lazy Loading — Code-splitting for the Nebular sample page
- 🛠️ TypeScript 5.8 — Full strict-mode TypeScript
- Node.js >= 20 (LTS recommended)
- npm >= 10
git clone https://github.com/ehsanshrz/angular-universal-nebular-theme.git
cd angular-universal-nebular-themenpm installnpm start
# or
npx ng serveNavigate to http://localhost:4200. The app will automatically reload on file changes.
Build the client and server bundles together:
npm run build:ssrOutput is placed in dist/angular-universal-nebular-theme/:
browser/— Static assets served to the clientserver/— Server-side Node.js bundle
After building, start the Express server:
npm run serve:ssrNavigate to http://localhost:4000.
Run the SSR dev server with live reload:
npm run serve:ssr:dev
# or
npx ng run angular-universal-nebular-theme:serve-ssrnpm test├── src/
│ ├── app/
│ │ ├── dashboard/ # Dashboard component (Tour of Heroes)
│ │ ├── hero-detail/ # Hero detail component
│ │ ├── hero-search/ # Hero search component
│ │ ├── heroes/ # Heroes list component
│ │ ├── messages/ # Messages component
│ │ ├── sample/ # Lazy-loaded Nebular layout sample
│ │ ├── app.module.ts # Root NgModule
│ │ ├── app.server.module.ts # SSR NgModule
│ │ ├── app-routing.module.ts # App routing
│ │ └── app.component.ts # Root component
│ ├── main.ts # Browser entry point
│ ├── main.server.ts # Server entry point
│ └── index.html # App shell
├── server.ts # Express SSR server (CommonEngine)
├── angular.json # Angular CLI workspace config
├── tsconfig.json # Base TypeScript config
├── tsconfig.app.json # App TypeScript config
└── tsconfig.spec.json # Test TypeScript config
Visit /sample to see the Nebular layout with sidebar in action. This route is lazy-loaded, demonstrating code-splitting with Nebular components.
This project uses Angular's built-in SSR support (@angular/ssr) with Express:
- The Angular CLI builds both browser and server bundles using the
applicationbuilder. server.tsstarts an Express server that usesCommonEngineto render each request server-side.- Static files (JS, CSS, images) are served directly from the
browser/output folder. - All other routes are handled by the Angular Universal engine, which returns fully-rendered HTML.
This improves:
- SEO — Search engines receive fully rendered HTML
- First Contentful Paint (FCP) — Users see content before JavaScript loads
- Performance — Reduced time-to-interactive
| Package | Version | Purpose |
|---|---|---|
@angular/core |
^21.2 | Angular framework |
@nebular/theme |
^17.0 | Nebular UI components |
@angular/ssr |
^21.2 | Server-side rendering |
express |
^5.0 | HTTP server |
rxjs |
^7.8 | Reactive extensions |
zone.js |
~0.16 | Angular change detection |
| Command | Description |
|---|---|
npm start |
Start development server on port 4200 |
npm run build |
Build the application |
npm run build:ssr |
Build browser + server bundles for production |
npm run serve:ssr |
Serve production SSR build on port 4000 |
npm run serve:ssr:dev |
Start SSR dev server with live reload |
npm test |
Run unit tests with Karma |
npm run watch |
Build and watch for changes |
MIT