What's the proper way to integrate with react-oidc-context?
I am using
react-oidc-context
for auth, I want to integrate the router with it, but I do not want to go into the app without auth being loaded
Is there any way through which I can go to the router pending component and wait there for isLoading
to become false
?2 Replies
fair-rose•10mo ago
you could create a layout, say _authenticatedLayout, and in there do your authentication in beforeLoad.
Before load is cool because you can just throw a redirect from there, and if you want to have some auth things globally accesible for all parents, use RouteContext, and then you just return it from beforeLoad and it is available in all child routes
So in your case it may look like this:
and then wherever you are creating your root route, it should look something like:
fair-roseOP•10mo ago
This does not fix my issue, I want to wait for the auth to be ready, not authenticated, I am already doing the above. I just want to wait for
auth.isLoading
to become false
before going forward, as auth.isAuthenticated
is false
while auth is loading even if the credentials are available (in localStorage
)
and i'd love for it to be managed by the router pending component, cause I know I could just return a loading component in <App />
where I use useAuth
to pass the auth to the router context