# Auth0 react SDK -- way to check for authed user without using client-side hooks

**URL:** <https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844>\
**Category:** Get Help\
**Tags:** react, login, auth0\
**Created:** [December 20, 2022, 6:46pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844 "2022-12-20T18:46:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmb.programmer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmb.programmer/32/42090_2.png) [@dmb.programmer](https://community.auth0.com/u/dmb.programmer)\
**Post date:** [December 20, 2022, 6:46pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844/1 "2022-12-20T18:46:22Z")

</div>

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 🙂

Notes:

- Using an SPA with the auth0-react SDK
- REST based backend api

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 20, 2022, 7:10pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844/3 "2022-12-20T19:10:31Z")

</div>

Hi @dmb.programmer,

Welcome to the Auth0 Community!

I understand you are looking for a way to check if a user is authenticated with the Auth0 React SDK.

To do so, I recommend using the [`useAuth0`](https://auth0.github.io/auth0-react/modules.html#useAuth0) hook to call the [`isAuthenticated`](https://auth0.github.io/auth0-react/interfaces/Auth0ContextInterface.html#isAuthenticated) method.

May I help you with anything else?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![dmb.programmer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmb.programmer/32/42090_2.png) [@dmb.programmer](https://community.auth0.com/u/dmb.programmer)\
**Post date:** [December 21, 2022, 3:37pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844/4 "2022-12-21T15:37:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dmb.programmer](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dmb.programmer/32/42090_2.png) [@dmb.programmer](https://community.auth0.com/u/dmb.programmer)\
**Post date:** [December 21, 2022, 3:38pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844/5 "2022-12-21T15:38:32Z")

</div>

The useAuth0 hook has to be making some api call tho right?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 23, 2022, 11:06pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844/6 "2022-12-23T23:06:55Z")

</div>

Hi @dmb.programmer,

Thank you for your responses.

> [@dmb.programmer](#):
>
> check if a user is authenticated WITHOUT using the useAuth0 hook

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).

Does that help?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 6, 2023, 11:07pm UTC](https://community.auth0.com/t/auth0-react-sdk-way-to-check-for-authed-user-without-using-client-side-hooks/96844/7 "2023-01-06T23:07:43Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
