# Keep users logged in for a month or more using token rotation in cloud-based next.js webapps

**URL:** <https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504>\
**Category:** Get Help\
**Tags:** rotating-refresh-tokens, sessions\
**Created:** [February 21, 2026, 11:03am UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504 "2026-02-21T11:03:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![philipbattle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/philipbattle/32/56023_2.png) [@philipbattle](https://community.auth0.com/u/philipbattle)\
**Post date:** [February 21, 2026, 11:03am UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504/1 "2026-02-21T11:03:51Z")

</div>

Using`react-native-auth0` with “Allow Refresh Token Rotation” enabled, our app allows users to stay logged in for the “Maximum Refresh Token Lifetime” which we have set to a year. We call getCredentials() to get the accessToken for api calls which i assume refreshes if necessary. Great.

Using an identical auth0 configuration for our @opennextjs/cloudflare webapp which uses @auth0/nextjs-auth0, users are routinely logged out after a few days, even though we similarly call getAccessToken() for the api calls.

What is the recommended approach to keep users logged in for a month or more using token rotation in cloud-based next.js webapps?

Many thanks.

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [February 23, 2026, 4:50pm UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504/3 "2026-02-23T16:50:43Z")

</div>

Hi @philipbattle

Welcome to the Auth0 Community!

Can you please share what is your current:

- Refresh Token configuration inside the Auth0 Dashboard
- Session lifetime configuration under Dashboard → Settings → Advanced
- You SDK configuration → Do you use `refresh: true` when using `getAccessToken()` or are you passing in the `offline_access` scope and the proper `audience`?

From what I understand, the token refresh might be failing on your web application because the user’s session is being terminated due to inactivity or has expired (due to the tenant settings). Since the application is trying to refresh a session that does not exist, it basically logs out the users.

Looking forward to your reply!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [March 2, 2026, 4:46pm UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504/4 "2026-03-02T16:46:43Z")

</div>

Hi again @philipbattle

Since you have not replied back, I will be marking my previous reply as the Solution.

If you need further assistance, you can let me know or you can post again on the Community!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![philipbattle](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/philipbattle/32/56023_2.png) [@philipbattle](https://community.auth0.com/u/philipbattle)\
**Post date:** [March 3, 2026, 1:24pm UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504/5 "2026-03-03T13:24:52Z")

</div>

> [@nik.baleca](#):
>
> Refresh Token configuration inside the Auth0 Dashboard

Hi Nik,

Many thanks for the quick response an apologies for my slow one.

Here is the Refresh Token configuration inside the Auth0 Dashboard for our production tenant:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/1/d/1d965540e846382d765ef4f938c64e4462fb467d.png)

And here is the Session lifetime configuration under Dashboard → Settings → Advanced:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/8/5/85da0c7534449f8f79e930a73783ac0e8e4a7075.png)

Regarding the SDK configuration, we do not use `refresh: true` when using `getAccessToken()` and we do set `offline_access` scope and the proper `audience`.

As you clearly suggested, termination of the user’s session due to inactivity looks like the most likely reason. Our Idle Session Lifetime is set to a default 4320 minutes (3 days), which is likely causing our none active users to be logged out, but i see 3 days is the maximum allowed value…

 ![image](https://global.discourse-cdn.com/auth0/original/3X/e/5/e58be4b8cace53be87202bd03c94bf005f82c09b.png)

Kind regards.

Philip

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [March 3, 2026, 3:59pm UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504/6 "2026-03-03T15:59:47Z")

</div>

Hi again @philipbattle

Thanks for the updates regarding the matter.

After further investigation, I realized I have overlooked the fact that you are using a nextjs based application with cloudflare.

To provide more information on the matter,the issue might be caused by the fact that the **`nextjs-auth0`** SDK enforces its own session lifetime logic via cookies, which is independent of the Refresh Token’s validity in Auth0. By default, the SDK has a hard session limit ( **Absolute Duration** ) of **7 days** and an inactivity limit ( **Rolling Duration** ) of **24 hours**. Even if your Refresh Token is valid for a year, the SDK will discard the session cookie after 7 days (or 24 hours of inactivity) unless you configure it otherwise. More information on the above can be found [here](https://github.com/auth0/nextjs-auth0/issues/264).

Otherwise, set these values in your `.env` or within your Cloudflare `wrangler.toml`/Dashboard:

```auto
#Values for a 30 day sesison
AUTH0_SESSION_ABSOLUTE_DURATION=2592000
AUTH0_SESSION_ROLLING_DURATION=2592000

#Values for 1 year session (if necessary)
AUTH0_SESSION_ABSOLUTE_DURATION=31557600
AUTH0_SESSION_ROLLING_DURATION=31557600

#Ensure the session cookie updates on every visit
#You most likely already have this enabled 
AUTH0_SESSION_ROLLING=true

```

Please be mindful of the cookie size limits imposed by Cloudflare where if they are too large, you will encounter 502s and 400s errors. Just make sure your claims inside the user session are not exceeding this limit.

Let me know if the above is helpful!

Kind Regards,  
Nik

---

<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:** [March 17, 2026, 3:59pm UTC](https://community.auth0.com/t/keep-users-logged-in-for-a-month-or-more-using-token-rotation-in-cloud-based-next-js-webapps/197504/7 "2026-03-17T15:59:49Z")

</div>

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