Auth0 useUser hook returns empty user object

Hey guys,
i recently added Auth0 to my personal project. After a lot of reasearch I found a working solution to callback to the right page. I added a custom a custom action:

* Handler that will be called during the execution of a PostLogin flow.
* @param {Event} event - Details about the user and the context in which they are logging in.
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login.
exports.onExecutePostLogin = async (event, api) => {

Now this works.

But the useUser hook is returning an empty user object:

import Header from '@/components/Header'
import Tile from '@/components/Tile'
import { useUser, withPageAuthRequired } from '@auth0/nextjs-auth0/client'

export default function Home() {
  const {user, error, isLoading} = useUser();
  if (isLoading) return <div>Loading...</div>
  if (error) return <div>{error.message}</div>
  if (user) return <div>{}</div>
  return (
    <main className='min-h-screen'>
      <Header page="/home"/>

I can log in at the route /api/auth/login. After that i shortly can see the loading, after that the page renders. So I guess the request is working.

This is my .env file:

AUTH0_SCOPE="openid profile"

Do you have any idea how to get the user object?

Thank you in advance.
Let me know if you need something else.


Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!

Did you ever figure it out? I’m struggling to get back a user, /api/auth/me is returning 204 and user is undefined