Skip to content

docs: add guide for route rendering strategies #62859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bencodezen
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

There is a new route rendering strategy guide.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@bencodezen bencodezen marked this pull request as ready for review July 28, 2025 18:44
@bencodezen bencodezen requested review from JeanMeche and atscott July 28, 2025 18:44
@angular-robot angular-robot bot added the area: docs Related to the documentation label Jul 28, 2025
@ngbot ngbot bot added this to the Backlog milestone Jul 28, 2025
@bencodezen bencodezen added action: review The PR is still awaiting reviews from at least one requested reviewer adev: preview labels Jul 28, 2025
Copy link

Deployed adev-preview for b181764 to: https://ng-dev-previews-fw--pr-angular-angular-62859-adev-prev-p8j9bpq7.web.app

Note: As new commits are pushed to this pull request, this link is updated after the preview is rebuilt.

| **SEO** | Limited - slower indexing, may miss dynamic content |
| **Initial load** | Slower - requires JavaScript download and execution |
| **Interactivity** | Immediate once loaded |
| **Server requirements** | Minimal - only serves static assets |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say that. The server needs to be configures to serve the index.html page for all client-side routes.


This generates static HTML files for each blog post: `blog/first-post/index.html`, `blog/second-post/index.html`, etc.

### SSG characteristics
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A section like the one in CSR starting with "All these routes automatically use CSR. Here's what happens:" would be welcome. It's critical, IMHO, to understand that once the initial page is loaded from the server, everything happens like in a CSR application (routing, http requests, etc.)


### How SSR works

With SSR, Angular runs on the server for each request:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Only for the first request which loads the application. After that, everything happens client-side.

| Aspect | Details |
| :---------------------- | :-------------------------------------------------- |
| **SEO** | Excellent - full HTML content available to crawlers |
| **Initial load** | Fast - content visible immediately |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slower than SSG though, since the server needs to generate the HTML on the fly, and thus get data from external resources

template: `
<header>Static header content</header>

@defer (on interaction) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be hydrate on interaction. Otherwise the widget is loaded and displayed only when interacting with the placeholder.


- **CSR**: Full application bundle loaded upfront
- **SSR**: Initial bundle can be smaller with code splitting
- **SSG**: Optimal with incremental hydration and `@defer`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be missing something, but I don't see how SSR/SSG affects the bundle size. What affects the bundle size is lazy loading, isn't it? And lazy loading isn't affected by SSR/SSG.
Deferred hydration I guess can impact bundle size, but I don't see why it would be different between SSR and SSG.
This section is too light to be really helpful, IMHO. I would skip it.


// Client-side routes (CSR)
'Cache-Control': 'public, max-age=86400'
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well, this section is too light to be helpful, IMHO. What are we caching here? Where would this be configured and how?
Besides, it's misleading. Static assets (like JS bundles) are static whether we use SSG SSR or CSR. ANd HTML pages, even when generated using SSG, change over time.

'Cache-Control': 'public, max-age=86400'
```

### Resource loading optimization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, IMHO, is off-topic. And I wouldn't blindly advise to preload all modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: review The PR is still awaiting reviews from at least one requested reviewer adev: preview area: docs Related to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants