Is there any way at all to check if a user is authed via an API call or something? Currently we have to show loading spinners in our UI because the useAuth0 hook takes time (and is called after the component/page loads on the client) โ it would make much more sense to make an api call in a route loader instead of doing this logic while we render the UI. Considering moving to session based auth for this reason but would appreciate any thoughts
If you read my question you would understand that my goal is to check if a user is authenticated WITHOUT using the useAuth0 hook โ the problem that I have is that i can only use the hooks when my pages load (I would like to be able to make the auth check anywhere (i.e in functions, route loadings, SSR, etc) โ is there a way via the auth0 api to do this or something?
One workaround to using the useAuth0 hook that I can recommend is to leverage the information from the Access Token to determine if the user is authenticated.
For example, using the payload information from the Access Token, you could check if it has expired through the exp claim. If it has not yet expired, we can conclude that the user is authenticated.
Similarly, you could try using the access token to see if you can gain access to an API.
In short, you should be able to gain access if the user is authenticated (non-expired/non-revoked access token).