I’m building an SSR Angular app (with provided hydration) and I’m using Resolver and Guard functions. I noticed that they are running on both the server and the client. I believe that it is redundant to run these functions on both sides, because if the user requests a URL for example and the server decides to redirect to another page, it sends the code of the page it redirected to, the user sees everything as it should be, but in the background the logic of the resolver and the guards is executed again. And yes, I know I can exploit isPlatformBrowser
and isPlatformserver
, but if some logic depends on the router events (ResolveStart, ResolveEnd, NavigationCancel, etc.), it would still be executed unnecessarily.
Do you know if there is a way to hydrate the state of the router so that it doesn’t run on the client initially?
I posted this thread as issue in the Angular github, but they advised to post this issue here.