# NextJS-Auth0 Refresh Token setup

**URL:** <https://community.auth0.com/t/nextjs-auth0-refresh-token-setup/112088>\
**Category:** Get Help\
**Tags:** rotating-refresh-tokens, sessions\
**Created:** [July 26, 2023, 3:39am UTC](https://community.auth0.com/t/nextjs-auth0-refresh-token-setup/112088 "2023-07-26T03:39:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![alex.brett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex.brett/32/60157_2.png) [@alex.brett](https://community.auth0.com/u/alex.brett)\
**Post date:** [December 5, 2024, 11:32pm UTC](https://community.auth0.com/t/nextjs-auth0-refresh-token-setup/112088/3 "2024-12-05T23:32:09Z")

</div>

Hello @luiz!

It seems you’re getting an `Unknown or invalid refresh token` error. I found another post that has that error also using NextJS.

> [@"Unknown or invalid refresh token" error encountered for NextJS projects](https://community.auth0.com/t/unknown-or-invalid-refresh-token-error-encountered-for-nextjs-projects/109571):
>
> Hello, We are using the NextJS framework, and periodically (like 3± days), we will encounter an error for users. The errors are as follows: [AccessTokenError: The request to refresh the access token failed. CAUSE: invalid\_grant (Unknown or invalid refresh token.)] {\n code: 'ERR\_FAILED\_REFRESH\_GRANT',\n cause: IdentityProviderError: invalid\_grant (Unknown or invalid refresh token.)\n at IdentityProviderError.EscapedError [as constructor] (/var/task/node\_modules/@auth0/nextjs-auth0…

This post has a solution and the TL;DR for it is that using [refresh token rotation](https://auth0.com/docs/secure/tokens/refresh-tokens/refresh-token-rotation) this error can occur when the token expires. It also mentions a setting that should help with the issue. This post also links a few other similar post that are worth looking at.

I hope this helps!

Best,  
Alex

---

_[View the full topic](https://community.auth0.com/t/nextjs-auth0-refresh-token-setup/112088)._
