Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth0Provider user is not used when a custom profile route is set #1965

Open
6 tasks done
seanparmelee opened this issue Mar 13, 2025 · 0 comments · May be fixed by #1966
Open
6 tasks done

Auth0Provider user is not used when a custom profile route is set #1965

seanparmelee opened this issue Mar 13, 2025 · 0 comments · May be fixed by #1966

Comments

@seanparmelee
Copy link
Contributor

Checklist

Description

The Auth0Provider allows for an initial user to be passed, which is used as the fallback value for the /auth/profile route:

The issue is that if a custom profile route is set to something other than /auth/profile, then the initial user will not be used.

Reproduction

  1. Configure a custom profile route via the NEXT_PUBLIC_PROFILE_ROUTE environment variable. (ex: NEXT_PUBLIC_PROFILE_ROUTE=/api/me.
  2. In a server component, fetch a user and pass it to the Auth0Provider:
const session = await auth0.getSession();

...

return (
  <Auth0Provider user={session?.user}>
    {children}
  </Auth0Provider>
);
  1. In a child client component, use the useUser() hook to retrieve the user and render a field, such as the sub:
const user = userUser()

...

return (
  <div>User: {user?.sub || 'undefined'}</div>
);
  1. Log into your application and navigate to a page that uses the component from the previous step.
  2. Since the user was already fetched in a server component, the user's sub should immediately be rendered on the page, but notice that it briefly renders "undefined" first.

Additional context

No response

nextjs-auth0 version

4.0.3

Next.js version

14.2.24

Node.js version

22.14.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant