-
Notifications
You must be signed in to change notification settings - Fork 12k
feat(@angular/ssr): Add support for route matchers with fine-grained render mode control #29517
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
Conversation
caf7c9c
to
43fce31
Compare
…render mode control This commit adds support for custom route matchers in Angular SSR, allowing fine-grained control over the `renderMode` (Server, Client) for individual routes, including those defined with matchers. Routes with custom matchers are **not** supported during prerendering and must explicitly define a `renderMode` of either server or client. The following configuration demonstrates how to use glob patterns (including recursive `**`) to define server-side rendering (SSR) or client-side rendering (CSR) for specific parts of the 'product' route and its child routes. ```typescript // app.routes.ts import { Routes } from '@angular/router'; export const routes: Routes = [ { path: '', component: DummyComponent, }, { path: 'product', component: DummyComponent, children: [ { path: '', component: DummyComponent, }, { path: 'list', component: DummyComponent, }, { matcher: () => null, // Example custom matcher (always returns null) component: DummyComponent, }, ], }, ]; ``` ```typescript // app.routes.server.ts import { RenderMode, ServerRoute } from '@angular/ssr'; export const serverRoutes: ServerRoute[] = [ { path: '**', renderMode: RenderMode.Client }, { path: 'product', renderMode: RenderMode.Prerender }, { path: 'product/list', renderMode: RenderMode.Prerender }, { path: 'product/**/overview/details', renderMode: RenderMode.Server }, ]; ``` Closes angular#29284
43fce31
to
f857877
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me, did we want to run this by Andrew Scott before merging or is this straightforward enough to be unobjectionable at this stage?
Also is there anything worth documenting on adev for custom route matchers and SSR?
@dgp1130, I think this is simply enough. Re documentation, I will be working on that later next week |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This commit adds support for custom route matchers in Angular SSR, allowing fine-grained control over the
renderMode
(Server, Client) for individual routes, including those defined with matchers.Routes with custom matchers are not supported during prerendering and must explicitly define a
renderMode
of either server or client.The following configuration demonstrates how to use glob patterns (including recursive
**
) to define server-side rendering (SSR) or client-side rendering (CSR) for specific parts of the 'product' route and its child routes.Closes #29284