nextjs-auth0: 4.0.0-beta.2 getSession returns null

Checklist

Description

following the documentation on the readme for login. Everything works correctly redirecting to /auth/login and back. No errors on the callback. In the onCallback there is a session object. When you are on a server component and run the below code it returns null for the session

Reproduction

  1. setup per instructions on the readme
  2. go to child route using app router and use the following code

import { auth0 } from "@/lib/auth0" const session = await auth0.getSession() return ( <> <main> <h1>Welcome, {session.user.name}!</h1> </main> );

Additional context

No response

nextjs-auth0 version

4.0.0-beta.2

Next.js version

15.0.3

Node.js version

22.9.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 28 (11 by maintainers)

Most upvoted comments

Definitely, I’ll update the docs so it’s more clear — thanks for the feedback!

Hi @guabu, just want to confirm that today I’ve re run the same use case and now it’s working correctly. I fear that this was caused by a misconfiguration on the callback url. I was testing using localhost as callback, but the experiment that gave getSession null was executed with a mobile phone connected on the same wifi. So when I ran the experiment reaching the site on 192.168.1.66 the callback redirected towards localhost:3000/auth/callback?code=1234..., giving no chance to the nextjs app to authenticate correctly the user. I apologize for adding noise, I think this is the expected behaviour from nextjs-auth0. Thanks and have a beautiful day