Skip to content
Back to skills

Angular Ssr

ASecurity

Angular SSR with @angular/ssr, hydration, and prerendering. Covers server-side rendering setup, transfer state, and deployment. USE WHEN: user mentions "Angular SSR", "server-side rendering", "Angular Universal", "@angular/ssr", "hydration", "prerendering", "Angular SEO" DO NOT USE FOR: Next.js SSR - use `nextjs`, Nuxt SSR - use `vue-composition`, SvelteKit SSR - use `svelte`

  • 31 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
ai-agentstypescriptgobashvueangularnextjsexpressdocumentation

Works with

  • cli
  • mcp

Security analysis

A100/100

Scanned September 8, 2026

npx -y skills add claude-dev-suite/claude-dev-suite --skill angular-ssr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Angular Ssr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Angular Ssr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/claude-dev-suite-angular-ssr/badge)](https://www.skillsdirectory.com/skills/claude-dev-suite-angular-ssr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: angular-ssr
description: |
  Angular SSR with @angular/ssr, hydration, and prerendering.
  Covers server-side rendering setup, transfer state, and deployment.

  USE WHEN: user mentions "Angular SSR", "server-side rendering", "Angular Universal",
  "@angular/ssr", "hydration", "prerendering", "Angular SEO"

  DO NOT USE FOR: Next.js SSR - use `nextjs`, Nuxt SSR - use `vue-composition`,
  SvelteKit SSR - use `svelte`
allowed-tools: Read, Grep, Glob, Write, Edit
---
# Angular SSR - Quick Reference

> **Deep Knowledge**: Use `mcp__documentation__fetch_docs` with technology: `angular`, topic: `ssr` for comprehensive documentation.

## Setup

```bash
# Add SSR to existing project
ng add @angular/ssr
```

This creates:
- `server.ts` - Express server entry point
- `src/app/app.config.server.ts` - Server-specific providers
- Updates `angular.json` with server builder

## Server Configuration

```typescript
// app.config.server.ts
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { provideServerRoutesConfig } from '@angular/ssr';
import { appConfig } from './app.config';
import { serverRoutes } from './app.routes.server';

const serverConfig: ApplicationConfig = {
  providers: [
    provideServerRendering(),
    provideServerRoutesConfig(serverRoutes),
  ]
};

export const config = mergeApplicationConfig(appConfig, serverConfig);
```

## Route-Level Rendering Modes

```typescript
// app.routes.server.ts
import { RenderMode, ServerRoute } from '@angular/ssr';

export const serverRoutes: ServerRoute[] = [
  { path: '', renderMode: RenderMode.Prerender },           // Static at build time
  { path: 'dashboard', renderMode: RenderMode.Server },      // SSR per request
  { path: 'profile/**', renderMode: RenderMode.Client },     // Client-only (SPA)
  { path: '**', renderMode: RenderMode.Server },              // Default: SSR
];
```

## Hydration

```typescript
// app.config.ts - Hydration is enabled by default with @angular/ssr
export const appConfig: ApplicationConfig = {
  providers: [
    provideClientHydration(),  // Included automatically
  ]
};
```

## Platform Checks

```typescript
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import { PLATFORM_ID, inject } from '@angular/core';

@Component({ ... })
export class MyComponent {
  private platformId = inject(PLATFORM_ID);

  ngOnInit() {
    if (isPlatformBrowser(this.platformId)) {
      // Browser-only code (localStorage, window, DOM manipulation)
      window.addEventListener('scroll', this.onScroll);
    }
  }
}

// Or use afterNextRender for one-time browser init
import { afterNextRender } from '@angular/core';

@Component({ ... })
export class ChartComponent {
  constructor() {
    afterNextRender(() => {
      // Runs only in browser after first render
      this.initChart();
    });
  }
}
```

## Anti-Patterns

| Anti-Pattern | Why It's Bad | Correct Approach |
|--------------|--------------|------------------|
| Direct `window`/`document` access | Breaks SSR | Use `isPlatformBrowser()` |
| No hydration | Full page re-render | Enable `provideClientHydration()` |
| SSR for auth-only pages | Wasted server resources | Use `RenderMode.Client` |
| Ignoring transfer state | Double data fetch | Hydration handles this automatically |

## Quick Troubleshooting

| Issue | Likely Cause | Solution |
|-------|--------------|----------|
| Hydration mismatch | DOM changed before hydration | Avoid DOM manipulation in `ngOnInit` |
| `window is not defined` | Server-side access | Guard with `isPlatformBrowser()` |
| Slow SSR | Heavy computation | Move to client with `@defer` |
| SEO not working | Client-only rendering | Use `RenderMode.Server` or `Prerender` |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.