We are using the useUser() client side method in nextjs SDK to retrieve the user details i am getting only the basic user profile, not getting any usermetadata attributes, though i have added the usermetadata as claims in the ID token, getting the details correctly in ID token but not in useUser() response why?
can anyone suggest what might be the issue
In the case of the NextJS SDK, the client must be configured to save the additional claims added to the token otherwise they will be filtered out since they are not part of the default claims. You can read more about that in our documentation and this small tutorial I have made on our DevHub forum.
You will need to add the following piece of code to your application in order for any added custom claims to be included.
import { Auth0Client } from "@auth0/nextjs-auth0/server";
export const auth0 = new Auth0Client({
async beforeSessionSaved(session, idToken) {
return session;
}
});