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

fix: use NEXT_PUBLIC_PROFILE_ROUTE in Auth0Provider #1966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

seanparmelee
Copy link
Contributor

📋 Changes

Similar to what's done in useUser, first check process.env.NEXT_PUBLIC_PROFILE_ROUTE and fallback to "/auth/profile" when setting the fallback data for the profile route.

📎 References

Fixes #1965

🎯 Testing

  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. Confirm that the logged-in user's sub is immediately visible on the screen and that there isn't a brief period where "undefined" is first shown.

@seanparmelee seanparmelee requested a review from a team as a code owner March 13, 2025 22:58
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 this pull request may close these issues.

Auth0Provider user is not used when a custom profile route is set
1 participant