# Auth0 NextJS get AccessToken without SSR

**URL:** <https://community.auth0.com/t/auth0-nextjs-get-accesstoken-without-ssr/147818>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [September 23, 2024, 4:43pm UTC](https://community.auth0.com/t/auth0-nextjs-get-accesstoken-without-ssr/147818 "2024-09-23T16:43:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![badpiggie](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/badpiggie/32/31836_2.png) [@badpiggie](https://community.auth0.com/u/badpiggie)\
**Post date:** [September 23, 2024, 4:43pm UTC](https://community.auth0.com/t/auth0-nextjs-get-accesstoken-without-ssr/147818/1 "2024-09-23T16:43:33Z")

</div>

I was playing with the [Auth0 NextJS Sample](https://github.com/auth0-samples/auth0-nextjs-samples). It gives `sessionToken` instead of `accessToken`. In order to retrieve `accessToken`, I have to do something as follows:

```auto
import { getAccessToken } from '@auth0/nextjs-auth0';
const { accessToken } = await getAccessToken(req, res, {
      scopes: ['read:shows']
});

```

But the problem is the above code only runs in `SSR`. I am looking forward for a solution that works purely on CSR. Is there any workaround?

---

<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:** [November 4, 2024, 5:11pm UTC](https://community.auth0.com/t/auth0-nextjs-get-accesstoken-without-ssr/147818/3 "2024-11-04T17:11:52Z")

</div>

Hi @badpiggie,

Welcome to the Auth0 Community!

Looking at the [Auth0 Next.JS SDK](https://auth0.github.io/nextjs-auth0/index.html), there isn’t a specific `sessionToken` property, as you shared. The correct property to get an access token should be [`getAccessToken()`](https://auth0.github.io/nextjs-auth0/types/session_get_access_token.GetAccessToken.html).

If you need to access the tokens from the client side, you could create an API route to generate the access token securely. Then, call the API route from the client side to get the access token.

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:** [November 18, 2024, 5:12pm UTC](https://community.auth0.com/t/auth0-nextjs-get-accesstoken-without-ssr/147818/4 "2024-11-18T17:12:51Z")

</div>

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