Skip to content

Ability to Prerender Specific Routes Only via CLI or Build Options #31221

@apappas1129

Description

@apappas1129

Which @angular/* package(s) are relevant/related to the feature request?

No response

Description

Currently, Angular's SSG (Static Site Generation) system always prerenders all routes defined in app.routes.server.ts when using ng build --configuration=production.

However, in large-scale, CMS-driven applications, this is often too expensive — especially when only a small subset of dynamic routes (e.g. articles, products, etc.) has changed.

Use Case:

For example:

// app.routes.server.ts
{
  path: 'article/:articleId',
  renderMode: RenderMode.Prerender,
  async getPrerenderParams() {
    return ['2025-new-post', '2024-old-post'].map(id => ({ articleId: id }));
  },
  fallback: PrerenderFallback.Server,
}

When a new article is published, or an existing one is updated, we want to prerender only that article's route — not the entire site. We’re building a webhook from our CMS to trigger a pipeline, but ng build does not support selectively prerendering specific routes.

This forces us to:

  • Rebuild all pages unnecessarily
  • Waste build time and resources
  • Overwrite unchanged prerendered content

The closest workaround is using the low-level @angular/ssg API (e.g. via a custom scripts/prerender-specific.ts), but this is not viable in Angular v17–20 as the @angular/ssg package is not public yet.

References:
https://stackoverflow.com/questions/79670012/how-to-pre-render-specific-route-on-cli

Proposed solution

Please provide a way to build/prerender only a specific subset of routes — for example:

ng prerender --routes=/article/2025-new-post,/article/2024-old-post

Benefits:

  • Better integration with headless CMS/webhooks
  • Efficient incremental builds
  • Much faster deployment cycles
  • Avoids regenerating unchanged routes

Alternatives considered

expose @angular/ssg API

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions