Extending properties on nextjs useUser

Which SDK this is regarding: api/auth/me route / userProfile
SDK Version: 1.3.0
Platform Version: Vercel

Hi. I’m new to the auth0-nexjs. I am trying to add more properties to the useUser object
(fetches userinfo from /api/auth/me)

struggling to add properties like app_metadata.[some-prop].
I would like to use the useUser hook on components to render different viewa depending on a custom prop.

Hi @digvalley,

Welcome to the Community!

The /api/auth/me endpoint provides info from the ID Token payload. To add additional data, you can add custom claims to the ID Token from within a rule:

function (user, context, callback) {
  const namespace = 'https://my-app.example.com/';
  context.idToken[namespace + 'app_metadata'] = user.app_metadata || 'no app metadata';
  callback(null, user, context);

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.