Route-specific app-shell: prerendering dynamic parameterized pages #29425
Labels
area: @angular/ssr
feature: under consideration
Feature request for which voting has completed and the request is now under consideration
feature
Issue that requests a new feature
Which @angular/* package(s) are relevant/related to the feature request?
platform-server
Description
We have a use case, where we would like to always show the same prerendered page skeleton/carcass on a route that has dynamic parameters.
Looking at the new Angular server documentation, I do not see such option https://angular.dev/guide/hybrid-rendering#parameterized-routes.
Basically we would like
posts/:id
to return a single prerendered page for any:id
parameter.This page would show a loading skeleton and would let the browser handle the exact
:id
and the logic related to it.Proposed solution
Add a wildcard
**
route option that would indicate to Angular that this prerendered page handles any dynamic route parameters.These wildcards could be used as the dynamic parameter in the build time when prerendering happens. It would be the component's responsibility to correctly handle the
**
parameter and show some parameter-agnostic content (loaders/skeletons) that would then be prerendered by Angular and served by the server accordingly.How it could look in
app.routes.server.ts
:Excerpt from the imaginary
post.component.ts
:Alternatives considered
I am currently considering:
server.ts
with a middleware that runs before any middleware generated by Angular CLI.app.routes.server.ts
:server.ts
:I have tested this approach and it works fine, however, it feels pretty hacky.
The text was updated successfully, but these errors were encountered: