# Auth0 NextJS - Refresh Sessions

**URL:** <https://community.auth0.com/t/auth0-nextjs-refresh-sessions/147540>\
**Category:** Get Help\
**Tags:** authentication-sessions, sessions\
**Created:** [September 19, 2024, 12:01pm UTC](https://community.auth0.com/t/auth0-nextjs-refresh-sessions/147540 "2024-09-19T12:01:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dylanbourbotte6](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dylanbourbotte6/32/60620_2.png) [@dylanbourbotte6](https://community.auth0.com/u/dylanbourbotte6)\
**Post date:** [September 19, 2024, 12:01pm UTC](https://community.auth0.com/t/auth0-nextjs-refresh-sessions/147540/1 "2024-09-19T12:01:00Z")

</div>

Hello,

I’m using ReactJS with NextJS and the Auth0 SDK for my application. I’ve integrated `<UseProvider>` in my `layout.tsx` file, and the login, signup, and logout functionalities work perfectly.

I’ve also integrated the Stripe payment API to allow users to subscribe to the premium mode. After a successful payment, I call my own API using Auth0’s API Management to update the user’s role to “premium.”

However, I can’t figure out how to update the user’s session on the client side (ReactJS/NextJS) without logging them out, in order to give them access to certain premium resources in my app, etc, so i need to access rôle, i have already create a actions but its for post login…

Do you have any ideas or solutions to solve this issue?

Thanks you,  
Dylan.

---

<div class="post-metadata">

**Author:** ![ale.vesga1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ale.vesga1/32/60921_2.png) [@ale.vesga1](https://community.auth0.com/u/ale.vesga1)\
**Post date:** [December 12, 2024, 7:51am UTC](https://community.auth0.com/t/auth0-nextjs-refresh-sessions/147540/3 "2024-12-12T07:51:52Z")

</div>

Hi @dylanbourbotte6,

Welcome to the Auth0 by Okta Community!

To fix this, you must obtain a refresh token. One way to do so is to set the refresh value equal to true. Take a look at the sample code below, along with the relevant documentation for more details.

```auto
Modify the session after refresh

// pages/api/my-handler.js
import { getAccessToken } from '@auth0/nextjs-auth0';

const afterRefresh = (req, res, session) => {
  session.user.customProperty = 'foo';
  delete session.idToken;
  return session;
};

export default async function MyHandler(req, res) {
  const accessToken = await getAccessToken(req, res, {
    refresh: true,
    afterRefresh,
  });
};

```

- [AccessTokenRequest | @auth0/nextjs-auth0](https://auth0.github.io/nextjs-auth0/interfaces/session_get_access_token.AccessTokenRequest.html#refresh)
- [nextjs-auth0/EXAMPLES.md at main · auth0/nextjs-auth0 · GitHub](https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#getting-a-refresh-token)

Hope this helps!

---

<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:** [December 26, 2024, 7:53am UTC](https://community.auth0.com/t/auth0-nextjs-refresh-sessions/147540/5 "2024-12-26T07:53:21Z")

</div>

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