Replies: 1 comment 7 replies
-
|
I would keep the auth state limited to middleware/loader/action functions, then return from a loader the current auth state and use the useRouteLoaderData hook to access it in React. |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, this is a question about Data Mode. I'm happy to see a recommended way to handle authenticated routes in the docs.
However, what is the best way to do this if I need to access the
userContextoutside of React Router or React? I am wary of using Zustand for this because then in the react tree you would have to avoid theuseStoreapi unless you want race conditions when navigating between authenticated and unauthenticated routes.I wonder if one should use
getContext?or forget context and just use a global variable?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions