[next.js] user property exposed by getSession() is null on server side component

Hi everyone,

I am building a next.js application. I used the basic example for checking if a user is logged in in a server side component as shown in the Auth0 application quick start.

import { getSession } from '@auth0/nextjs-auth0';

export default async function ProfileServer() {
  const { user } = await getSession();

  return (
      user && (
          <div>
            <img src={user.picture} alt={user.name} />
            <h2>{user.name}</h2>
            <p>{user.email}</p>
          </div>
      )
  );
}

However, whenever the user is not signed in, I get the following error:
Error: Cannot destructure property ‘user’ of ‘(intermediate value)’ as it is null.

I would expect this server side component to not return anything if a user is not logged in. What am I doing wrong?

Thanks for your help!