# NextJS useUser Not Getting App Metadata

**URL:** <https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553>\
**Category:** Get Help\
**Tags:** nextjs, auth0\
**Created:** [July 21, 2021, 9:42pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553 "2021-07-21T21:42:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanwhite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryanwhite/32/13404_2.png) [@ryanwhite](https://community.auth0.com/u/ryanwhite)\
**Post date:** [July 21, 2021, 9:42pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/1 "2021-07-21T21:42:57Z")

</div>

I am trying to retrieve my app\_metadata through the useUser nextJS hook but it keeps failing.

I followed this answer to setup a rule to return the metadata but still do not get the info when I call useUser.

> [@Nextjs-auth0: How to get app\_metadata properties from session object in afterCallback()](https://community.auth0.com/t/nextjs-auth0-how-to-get-app-metadata-properties-from-session-object-in-aftercallback/59667):
>
> SDK: @auth0/nextjs-auth0 Version: v1.2.0 Hi all, First time user of Auth0 and Next.js here so excuse any oversight in my question below. I want to add two custom properties (I think they’re called claims in the auth world) to each user. These properties essentially represent the User profile type and a particular resource they have access to. I’ve added the two properties under app\_metadata from the Auth0 dashboard and am using Passwordless Email login using a code. Now, in Next.js I want …

I am very stuck and have tried setting up rules/claims to do this but have made no progress.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 22, 2021, 4:38pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/3 "2021-07-22T16:38:59Z")

</div>

Hi @ryanwhite,

Welcome to the Auth0 Community!

How is it failing? Can you try to decode the token with [jwt.io](http://jwt.io) and see if the claim you are expecting is there?

---

<div class="post-metadata">

**Author:** ![ryanwhite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryanwhite/32/13404_2.png) [@ryanwhite](https://community.auth0.com/u/ryanwhite)\
**Post date:** [July 22, 2021, 5:14pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/4 "2021-07-22T17:14:37Z")

</div>

Hello and thank you @dan.woda

So maybe I am misunderstanding how I should be retrieving the info but when I call `useUser` in nextjs it returns the user info but no metadata.

This is my rule

```auto
function(user, context, callback) {
  const namespace = 'https://myapp.example.com/';
  context.idToken[namespace + 'stripe_id'] = user.app_metadata.stripe_id;
	callback(null, user, context);
}

```

Then this is what useUser returns

```auto
email: "EMAIL_HERE"
email_verified: false
name: "EMAIL_HERE"
nickname: "hello"
picture: "GRAVATAR_HERE"
sub: "auth0|AUTH0_ID"
updated_at: "2021-07-21T21:47:30.606Z"

```

I have set in the auth0 dashboard the app\_metadata of  
{  
“stripe\_id”: “test-value”  
}

---

<div class="post-metadata">

**Author:** ![ryanwhite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryanwhite/32/13404_2.png) [@ryanwhite](https://community.auth0.com/u/ryanwhite)\
**Post date:** [July 22, 2021, 5:23pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/5 "2021-07-22T17:23:07Z")

</div>

Oh man I feel dumb. I logged out of my app and back in and it started working. How would I be able to force the retrieval of this data without forcing users to log in/out again @dan.woda?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 23, 2021, 8:21pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/6 "2021-07-23T20:21:58Z")

</div>

@ryanwhite,

It must be that the initial token is getting issued before the stripe ID is set in the user’s metadata. How are you setting that value in the user’s app\_metadata?

---

<div class="post-metadata">

**Author:** ![ryanwhite](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ryanwhite/32/13404_2.png) [@ryanwhite](https://community.auth0.com/u/ryanwhite)\
**Post date:** [July 27, 2021, 6:28pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/7 "2021-07-27T18:28:28Z")

</div>

I have switched to setting it in my app with the management API and it seems to be working okay. I will keep testing but I think I have got it figure out. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [July 27, 2021, 7:12pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/8 "2021-07-27T19:12:55Z")

</div>

Glad you found a solution!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 11, 2021, 7:13pm UTC](https://community.auth0.com/t/nextjs-useuser-not-getting-app-metadata/66553/9 "2021-08-11T19:13:31Z")

</div>

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