Skip to content

Get resource and cache it with SSR and Hydration #3117

Answered by gbj
levap5 asked this question in Q&A
Discussion options

You must be logged in to vote

Ultimately, there are many number of ways to handle this, right?

  • Your solution, where you synchronize a resource with a signal — fine. (Probably better done with an effect than doing it during rendering in Suspense).
  • The solution I suggested, which will load the user once during server rendering, then set it whenever you log in/out. (This doesn't reload the resource every time you navigate between pages on the client.)
  • Use nested routing, providing a wrapping parent Route around the only pages you want to load the user data (Login and UserPage), loading the resource in the parent route and providing it to the children

It's your application; you can pick whichever one's appropriate for y…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@levap5
Comment options

@gbj
Comment options

@levap5
Comment options

@gbj
Comment options

Answer selected by levap5
@levap5
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants