🦅 Angular Universal with NestJS

Add server-side rendering to Angular with Nest.js

Create a server module using Angular Universal with the NestJS schematic.

Nest Universal Schematic

Steps

Add Universal and Nest

command line
ng add @nestjs/ng-universal

npm run build:ssr
npm run serve:ssr
file_type_ng_component_ts server/main.ts
import { NestFactory } from '@nestjs/core';
import { ApplicationModule } from './app.module';

async function bootstrap() {
  const app = await NestFactory.create(ApplicationModule);
  app.setGlobalPrefix('api');
  await app.listen(process.env.PORT || 8080); // <-- update this line
}
bootstrap();

Questions? Let's chat

Open Discord