# \#nextjs

**URL:** https://community.auth0.com/tag/nextjs/804.md

[Latest](https://community.auth0.com/latest.md) · [Categories](https://community.auth0.com/categories.md) · [Tags](https://community.auth0.com/tags.md)

---

## [How to implement secondary account authentication for server-side account linking with Next.js SDK?](https://community.auth0.com/t/how-to-implement-secondary-account-authentication-for-server-side-account-linking-with-next-js-sdk/203881)

<div class="topic-metadata">

**Author:** [@Vestels](https://community.auth0.com/u/Vestels)\
**Replies:** 1\
**Last updated:** [October 5, 2026, 4:46pm UTC](https://community.auth0.com/t/how-to-implement-secondary-account-authentication-for-server-side-account-linking-with-next-js-sdk/203881 "2026-10-05T16:46:05Z")

</div>

Hi, I’m using Next.js 16 + @auth0/nextjs-auth0 4.29.x, Auth0 and a Spring Boot backend with the Auth0 Management API. I’m trying to implement user-initiated account linking liek this: Primary Auth0 session ↓ "Conn…

---

## [Receiving JWE token instead of JWT in Next.js app session](https://community.auth0.com/t/receiving-jwe-token-instead-of-jwt-in-next-js-app-session/167855)

<div class="topic-metadata">

**Author:** [@rsacks](https://community.auth0.com/u/rsacks)\
**Replies:** 6\
**Last updated:** [July 7, 2026, 11:06am UTC](https://community.auth0.com/t/receiving-jwe-token-instead-of-jwt-in-next-js-app-session/167855 "2026-07-07T11:06:13Z")

</div>

Hi, We are expecting, a JWT token. We can’t figure out why we are getting a JWE token instead. The only option I can find that would cause this is a plugin that is off. My understanding is JWT should be the default. I a…

---

## [Hands-On Workshop: Secure Your GenAI Assistant with Auth for GenAI](https://community.auth0.com/t/hands-on-workshop-secure-your-genai-assistant-with-auth-for-genai/188104)

<div class="topic-metadata">

**Author:** [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Replies:** 0\
**Last updated:** [June 17, 2025, 8:01pm UTC](https://community.auth0.com/t/hands-on-workshop-secure-your-genai-assistant-with-auth-for-genai/188104 "2025-06-17T20:01:17Z")

</div>

Ready to code? Join our 90-minute workshop, ““Auth-ing” Your GenAI Assistant: Implementing Auth and Tool Calling in Next.js-based Assistant with Auth for GenAI.” William Johnson, Senior Developer Advocate at Auth0, w…

---

## [Next.js Auth0 | External API service (without /api directory)](https://community.auth0.com/t/next-js-auth0-external-api-service-without-api-directory/85448)

<div class="topic-metadata">

**Author:** [@mennabah](https://community.auth0.com/u/mennabah)\
**Replies:** 4\
**Last updated:** [March 12, 2025, 10:08pm UTC](https://community.auth0.com/t/next-js-auth0-external-api-service-without-api-directory/85448 "2025-03-12T22:08:47Z")

</div>

Hi everyone We have an existing API service that we started building a few weeks ago. We’re about to kick off the frontend development using Next.js soon. We looked at the example projects and docs of the Next.js Auth0…

---

## [useUser only gets metadata updates after new user logs out and back in](https://community.auth0.com/t/useuser-only-gets-metadata-updates-after-new-user-logs-out-and-back-in/91091)

<div class="topic-metadata">

**Author:** [@steffanie](https://community.auth0.com/u/steffanie)\
**Replies:** 5\
**Last updated:** [February 18, 2025, 9:30pm UTC](https://community.auth0.com/t/useuser-only-gets-metadata-updates-after-new-user-logs-out-and-back-in/91091 "2025-02-18T21:30:05Z")

</div>

Continuing the discussion from NextJS useUser Not Getting App Metadata: I have a similar problem to the issue I’ve linked here. I have a postLogin action that sets some custom claims for a user, in order for us to read …

---

## [Next-auth/Auth0 e2e with Cypress test not working on host, but redirecting to universal flow](https://community.auth0.com/t/next-auth-auth0-e2e-with-cypress-test-not-working-on-host-but-redirecting-to-universal-flow/86683)

<div class="topic-metadata">

**Author:** [@rnnyrk](https://community.auth0.com/u/rnnyrk)\
**Replies:** 2\
**Last updated:** [January 29, 2025, 7:16pm UTC](https://community.auth0.com/t/next-auth-auth0-e2e-with-cypress-test-not-working-on-host-but-redirecting-to-universal-flow/86683 "2025-01-29T19:16:59Z")

</div>

Currently facing a complex issue where i want to authenticate my end-to-end test in Cypress using Auth0 and Next-auth. Already took me quite some effort using various different tutorials like; Testing with Cypress | Ne…

---

## [Nextjs - Constants Timeouts with doc. on live server](https://community.auth0.com/t/nextjs-constants-timeouts-with-doc-on-live-server/94860)

<div class="topic-metadata">

**Author:** [@santigamo](https://community.auth0.com/u/santigamo)\
**Replies:** 2\
**Last updated:** [December 20, 2024, 5:21pm UTC](https://community.auth0.com/t/nextjs-constants-timeouts-with-doc-on-live-server/94860 "2024-12-20T17:21:01Z")

</div>

Hi all! When I try to follow the following simple example and I deploy in vercel (Hobby Plan). I constantly receive the following error: Am I doing something wrong? I need some extra configuration to use WithPageAuth…

---

## [Next.js lose useUser() data after refresh a page which contains data of user](https://community.auth0.com/t/next-js-lose-useuser-data-after-refresh-a-page-which-contains-data-of-user/90324)

<div class="topic-metadata">

**Author:** [@njudev](https://community.auth0.com/u/njudev)\
**Replies:** 2\
**Last updated:** [December 11, 2024, 9:35pm UTC](https://community.auth0.com/t/next-js-lose-useuser-data-after-refresh-a-page-which-contains-data-of-user/90324 "2024-12-11T21:35:22Z")

</div>

Hello, I’m new here. Started to exploring auth0 and I faced a problem when I refresh page where I got user declared with const { user } = useUser(); and then everytime I refresh the page I lost my session (I don’t know…

---

## [Intermittent 'Failed to load previous state' on @auth0-nextjs SDK on Login](https://community.auth0.com/t/intermittent-failed-to-load-previous-state-on-auth0-nextjs-sdk-on-login/89872)

<div class="topic-metadata">

**Author:** [@peterghdevwhite](https://community.auth0.com/u/peterghdevwhite)\
**Replies:** 1\
**Last updated:** [December 4, 2024, 7:26pm UTC](https://community.auth0.com/t/intermittent-failed-to-load-previous-state-on-auth0-nextjs-sdk-on-login/89872 "2024-12-04T19:26:25Z")

</div>

Which SDK this is regarding: @auth0-nextjs SDK Version: 1.9.1 Platform Version: Next.js 12.2.0, Node 16.0.0 Code Snippets/Error Messages/Supporting Details/Screenshots: I’m randomly getting this error when trying …

---

## [NextJS getSession() is returning null](https://community.auth0.com/t/nextjs-getsession-is-returning-null/76233)

<div class="topic-metadata">

**Author:** [@Neo-Ciber94](https://community.auth0.com/u/Neo-Ciber94)\
**Replies:** 3\
**Last updated:** [April 5, 2023, 9:29pm UTC](https://community.auth0.com/t/nextjs-getsession-is-returning-null/76233 "2023-04-05T21:29:16Z")

</div>

I’m using NextJS 12 with Auth0 but when I try to access the session from an api/route is always null. import { getSession } from "@auth0/nextjs-auth0"; import { NextApiRequest, NextApiResponse } from "next"; export def…

---

## [NextJS - access\_denied (Script execution time exceeded)](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186)

<div class="topic-metadata">

**Author:** [@zachary.willard](https://community.auth0.com/u/zachary.willard)\
**Replies:** 5\
**Last updated:** [April 3, 2023, 10:04am UTC](https://community.auth0.com/t/nextjs-access-denied-script-execution-time-exceeded/87186 "2023-04-03T10:04:24Z")

</div>

Hello - I am trying to solve an intermittent issue where the client is unable to access the application after authenticating. We are using: Nextjs 12.1.6 @auth0/nextjs-auth0 1.9.0: GitHub - auth0/nextjs-auth0: Next.js…

---

## [Redirecting back to starting page dynamically with nextjs-auth0](https://community.auth0.com/t/redirecting-back-to-starting-page-dynamically-with-nextjs-auth0/71460)

<div class="topic-metadata">

**Author:** [@prnkdslv](https://community.auth0.com/u/prnkdslv)\
**Replies:** 2\
**Last updated:** [March 6, 2023, 9:11am UTC](https://community.auth0.com/t/redirecting-back-to-starting-page-dynamically-with-nextjs-auth0/71460 "2023-03-06T09:11:40Z")

</div>

Hello, I’m trying to figure out how to redirect users dynamically after login based on the page they accessed the login form from. In the app I’m currently trying to build, users can log in from “/” which is the home pa…

---

## [Redirect to external domain on logout](https://community.auth0.com/t/redirect-to-external-domain-on-logout/85091)

<div class="topic-metadata">

**Author:** [@cameron3](https://community.auth0.com/u/cameron3)\
**Replies:** 2\
**Last updated:** [January 6, 2023, 9:52pm UTC](https://community.auth0.com/t/redirect-to-external-domain-on-logout/85091 "2023-01-06T21:52:36Z")

</div>

Hey all, I’m currently writing an application where we’d like to redirect users to an external site on logout, for example they login and use “httpsL//thisdomain.com” but once they logout we’d like to send them to “\_htt…

---

## [How can I override the callback handler's redirect?](https://community.auth0.com/t/how-can-i-override-the-callback-handlers-redirect/89285)

<div class="topic-metadata">

**Author:** [@michaelschufi](https://community.auth0.com/u/michaelschufi)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 7:34pm UTC](https://community.auth0.com/t/how-can-i-override-the-callback-handlers-redirect/89285 "2022-12-07T19:34:43Z")

</div>

Hi I’m trying to redirect the user to his previous page. To do that, I set a cookie before the login handler runs and read the cookie in the callback handler’s afterCallback. (see code below) However, I always get redi…

---

## [Moving from @auth0/auth0-spa-js to @auth0/nextjs-auth0, stuck on RBAC](https://community.auth0.com/t/moving-from-auth0-auth0-spa-js-to-auth0-nextjs-auth0-stuck-on-rbac/95150)

<div class="topic-metadata">

**Author:** [@ggascoigne](https://community.auth0.com/u/ggascoigne)\
**Replies:** 2\
**Last updated:** [November 28, 2022, 9:25am UTC](https://community.auth0.com/t/moving-from-auth0-auth0-spa-js-to-auth0-nextjs-auth0-stuck-on-rbac/95150 "2022-11-28T09:25:21Z")

</div>

I have an app that uses @auth0/auth0-spa-js, gets an access token and based on roles in the token, dynamically adjusts the UI to render or skip various components. Note that this is generally at a component level and n…

---

## [Organisation Member Invitation flow results in state mismatch](https://community.auth0.com/t/organisation-member-invitation-flow-results-in-state-mismatch/70100)

<div class="topic-metadata">

**Author:** [@nicky.thorne](https://community.auth0.com/u/nicky.thorne)\
**Replies:** 3\
**Last updated:** [November 21, 2022, 11:36am UTC](https://community.auth0.com/t/organisation-member-invitation-flow-results-in-state-mismatch/70100 "2022-11-21T11:36:45Z")

</div>

Please include the following information in your post: SDK: nextjs-auth0 SDK Version: 1.5.0 Platform Version: Node v16.2.0 We are attempting to invite users to an organisation and are hitting an issue whereby the cal…

---

## [How to incorporate roles in the useUser hook from nextjs-auth0?](https://community.auth0.com/t/how-to-incorporate-roles-in-the-useuser-hook-from-nextjs-auth0/92361)

<div class="topic-metadata">

**Author:** [@faabiopk](https://community.auth0.com/u/faabiopk)\
**Replies:** 3\
**Last updated:** [October 14, 2022, 5:09pm UTC](https://community.auth0.com/t/how-to-incorporate-roles-in-the-useuser-hook-from-nextjs-auth0/92361 "2022-10-14T17:09:53Z")

</div>

Please include the following information in your post: Which SDK this is regarding: nextjs-auth0 SDK Version: 1.9.1 Platform Version: N/A Code Snippets/Error Messages/Supporting Details/Screenshots: Hi, I am stru…

---

## [Switch Organizations using Next.js](https://community.auth0.com/t/switch-organizations-using-next-js/91086)

<div class="topic-metadata">

**Author:** [@nick18](https://community.auth0.com/u/nick18)\
**Replies:** 1\
**Last updated:** [September 23, 2022, 2:18am UTC](https://community.auth0.com/t/switch-organizations-using-next-js/91086 "2022-09-23T02:18:35Z")

</div>

Hello there! There are a few other topics on these forums relating to this topic, but none of them specifically use next.js, and I wasn’t able to easily replicate what those others are asking. When users login to our a…

---

## [Best way to implement embedded login with session management?](https://community.auth0.com/t/best-way-to-implement-embedded-login-with-session-management/90774)

<div class="topic-metadata">

**Author:** [@vikas.dagar](https://community.auth0.com/u/vikas.dagar)\
**Replies:** 3\
**Last updated:** [September 19, 2022, 1:38pm UTC](https://community.auth0.com/t/best-way-to-implement-embedded-login-with-session-management/90774 "2022-09-19T13:38:18Z")

</div>

Please include the following information in your post: Which SDK this is regarding: SDK Version: 9.19.1 Platform Version: JavaScript Code Snippets/Error Messages/Supporting Details/Screenshots: We are developing embed…

---

## [How to give Access token a longer exp time?](https://community.auth0.com/t/how-to-give-access-token-a-longer-exp-time/90721)

<div class="topic-metadata">

**Author:** [@nacho](https://community.auth0.com/u/nacho)\
**Replies:** 1\
**Last updated:** [September 15, 2022, 6:45pm UTC](https://community.auth0.com/t/how-to-give-access-token-a-longer-exp-time/90721 "2022-09-15T18:45:29Z")

</div>

In our NextJS app (with next-auth library), the user session is good for 30 days. However, the API access token is only valid for 24 hours. Where in Auth0 Dashboard can I change API token expiration? “Token expiration…

---

## [Assign roles to Regular Web App in an action](https://community.auth0.com/t/assign-roles-to-regular-web-app-in-an-action/90097)

<div class="topic-metadata">

**Author:** [@steffanie](https://community.auth0.com/u/steffanie)\
**Replies:** 3\
**Last updated:** [September 8, 2022, 12:54am UTC](https://community.auth0.com/t/assign-roles-to-regular-web-app-in-an-action/90097 "2022-09-08T00:54:59Z")

</div>

Hello, I would like to assign a role to a user when they register an account on our app (regular web app in auth0). I’ve seen posts on how to do this with a Machine to Machine setup and auth0 Actions, but I have errors …

---

## [Next.js: Role access / claim check using withPageAuthRequired](https://community.auth0.com/t/next-js-role-access-claim-check-using-withpageauthrequired/89710)

<div class="topic-metadata">

**Author:** [@colinriddell](https://community.auth0.com/u/colinriddell)\
**Replies:** 1\
**Last updated:** [August 31, 2022, 2:47pm UTC](https://community.auth0.com/t/next-js-role-access-claim-check-using-withpageauthrequired/89710 "2022-08-31T14:47:25Z")

</div>

I’m using GitHub - auth0/nextjs-auth0: Next.js SDK for signing in with Auth0 and I’d like to use withPageAuthRequired (or similar ) to be able to conditionally disallow someone access to a page based on the result of a …

---

## [Getting unauthorized/access\_denied on getting token using refresh token](https://community.auth0.com/t/getting-unauthorized-access-denied-on-getting-token-using-refresh-token/88378)

<div class="topic-metadata">

**Author:** [@wkjljadlskfjklasjflw](https://community.auth0.com/u/wkjljadlskfjklasjflw)\
**Replies:** 3\
**Last updated:** [August 9, 2022, 11:02pm UTC](https://community.auth0.com/t/getting-unauthorized-access-denied-on-getting-token-using-refresh-token/88378 "2022-08-09T23:02:15Z")

</div>

This is a code snippet on my Nextjs project using nextauth to get new tokens followed this thread async function refreshAccessToken(token: any) { try { const url = \`${process.env.AUTH0\_ISSUER}/oauth/token?\` …

---

## [How to access Next.js API endpoint with JWT](https://community.auth0.com/t/how-to-access-next-js-api-endpoint-with-jwt/86853)

<div class="topic-metadata">

**Author:** [@CPU](https://community.auth0.com/u/CPU)\
**Replies:** 1\
**Last updated:** [July 25, 2022, 9:59pm UTC](https://community.auth0.com/t/how-to-access-next-js-api-endpoint-with-jwt/86853 "2022-07-25T21:59:09Z")

</div>

Hi, I need some help wrapping my brain around the right approach to granting users, native apps, and machine 2 machine apps access to my Nextjs API endpoint. To give you context, this is my stack: I’m buildng a Next.j…

---

## [Changing language in login for Next.js app is not work (nextjs-auth0/New Experience)](https://community.auth0.com/t/changing-language-in-login-for-next-js-app-is-not-work-nextjs-auth0-new-experience/87134)

<div class="topic-metadata">

**Author:** [@yskstdev](https://community.auth0.com/u/yskstdev)\
**Replies:** 4\
**Last updated:** [July 20, 2022, 8:12am UTC](https://community.auth0.com/t/changing-language-in-login-for-next-js-app-is-not-work-nextjs-auth0-new-experience/87134 "2022-07-20T08:12:30Z")

</div>

Which SDK this is regarding:@auth0/nextjs-auth0 SDK Version: 1.9.1 Hello I’m trying to change language in Universal Login page(New Experience). According to document, It need to do below select the language(in my …

---

## [NextJs Cookie lifetime - Security concerns?](https://community.auth0.com/t/nextjs-cookie-lifetime-security-concerns/86749)

<div class="topic-metadata">

**Author:** [@theo.camboulive](https://community.auth0.com/u/theo.camboulive)\
**Replies:** 2\
**Last updated:** [July 12, 2022, 10:56am UTC](https://community.auth0.com/t/nextjs-cookie-lifetime-security-concerns/86749 "2022-07-12T10:56:36Z")

</div>

Quick question: We are thinking to increase the Auth Cookie lifetime to 14 days instead of 1 as default. Is that something you would advise against security wise? Why do we need to do this? When a user comes back to our…

---

## [Next.js API Routes RBAC](https://community.auth0.com/t/next-js-api-routes-rbac/85540)

<div class="topic-metadata">

**Author:** [@valentin.vad.sh](https://community.auth0.com/u/valentin.vad.sh)\
**Replies:** 1\
**Last updated:** [June 27, 2022, 5:33pm UTC](https://community.auth0.com/t/next-js-api-routes-rbac/85540 "2022-06-27T17:33:52Z")

</div>

How to handle Roles and Permissions using Next.js API Routes? How to decode authToken or what is best practice to get user roles / permissions ? jwt.io says it is A256GCM encryption, and I am not sure what is the key t…

---

## [Mismatching error while using auth in Nextjs](https://community.auth0.com/t/mismatching-error-while-using-auth-in-nextjs/84649)

<div class="topic-metadata">

**Author:** [@Emmanueluzoezie](https://community.auth0.com/u/Emmanueluzoezie)\
**Replies:** 4\
**Last updated:** [June 10, 2022, 6:07pm UTC](https://community.auth0.com/t/mismatching-error-while-using-auth-in-nextjs/84649 "2022-06-10T18:07:24Z")

</div>

\*\*"error": { "message": "Callback URL mismatch. https://'http://localhost:3000'/api/auth/callback is not in the list of allowed callback URLs", "oauthError": "Callback URL mismatch. https://'http://localho…

---

## [Intermittent missing cookie issue resulting in unsuccessful logins](https://community.auth0.com/t/intermittent-missing-cookie-issue-resulting-in-unsuccessful-logins/84813)

<div class="topic-metadata">

**Author:** [@shyam\_p](https://community.auth0.com/u/shyam_p)\
**Replies:** 2\
**Last updated:** [June 10, 2022, 11:37am UTC](https://community.auth0.com/t/intermittent-missing-cookie-issue-resulting-in-unsuccessful-logins/84813 "2022-06-10T11:37:02Z")

</div>

I read this post in detail: BadRequestError: checks.state argument is missing - #4 by schalk.neethling, but unfortunately it doesn’t help me at all. We’re also running into (very intermittently), checks.state argument…

---

## [NextJs Auth0 - getAccessToken M2M Quota Limits?](https://community.auth0.com/t/nextjs-auth0-getaccesstoken-m2m-quota-limits/84736)

<div class="topic-metadata">

**Author:** [@stefano.brandoli23](https://community.auth0.com/u/stefano.brandoli23)\
**Replies:** 3\
**Last updated:** [June 10, 2022, 12:15am UTC](https://community.auth0.com/t/nextjs-auth0-getaccesstoken-m2m-quota-limits/84736 "2022-06-10T00:15:50Z")

</div>

Which SDK this is regarding: “@auth0/nextjs-auth0”: “1.9.0” Hi there, I’m setting up a NextJs application that will use Auth0 to login/signup, social logins included. This app needs to call our backend with informat…

[Next page](https://community.auth0.com/tag/nextjs/804.md?match_all_tags=true&page=1&tags%5B%5D=nextjs)
