# Custom claims in action no longer working after migrating from v3.8 to v4.8

**URL:** <https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864>\
**Category:** Get Help\
**Tags:** user-profile, user-management\
**Created:** [July 7, 2025, 10:07pm UTC](https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864 "2025-07-07T22:07:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![devops19](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/devops19/32/71813_2.png) [@devops19](https://community.auth0.com/u/devops19)\
**Post date:** [July 7, 2025, 10:07pm UTC](https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864/1 "2025-07-07T22:07:23Z")

</div>

I have some custom claims added in an action that has been working fine for some time. I am trying to migrate to the latest version of nextjs-auth0 and since having done so, I am no longer receiving the custom claims that are in the action. It still works if using the v3 version of nextjs-auth0.

I’ve looked through the documentation to make sure I have everything correct and I did notice that the more recent docs have you namespace the claims, which I have tried but that has not worked. The /profile endpoint and the user object from useUser() are only returning the following properties:

```auto
{
mail: "email_address"
email_verified: true
name: "name"
nickname: "nickname"
org_id: "org_"
picture: "picture_url"
sub: ""
}

```

However, if I use the access token and then call the /userinfo endpoint from auth0 I do get all the additional claims that I have defined. I don’t know why its just not working with the v4 client, am I missing something in the configuration of the client?

Here is an example of one of the claims I am trying to add

```auto
exports.onExecutePostLogin = async (event, api) => {
    const namespace = "https://myapp.example.com/";

    const organization = event.organization?.name;

    api.idToken.setCustomClaim(namespace + "org_name", organization);
};
```

---

<div class="post-metadata">

**Author:** ![devops19](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/devops19/32/71813_2.png) [@devops19](https://community.auth0.com/u/devops19)\
**Post date:** [July 7, 2025, 10:48pm UTC](https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864/2 "2025-07-07T22:48:00Z")

</div>

Ok, I just figured this out and putting the fix here for anyone else that had the same issue I did with the nextjs library. You have to configure the client to save the additional claims to the session, otherwise they will be filtered out since they are not part of the default claims.

If you add this it will return all the claims, including your custom ones. You just need to adjust this to only return the ones you need but this should help you get there.

```auto
import { Auth0Client } from "@auth0/nextjs-auth0/server";

export const auth0 = new Auth0Client({
  async beforeSessionSaved(session, idToken) {
    return session;
  }
});
```

---

<div class="post-metadata">

**Author:** ![cyclotron3k](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cyclotron3k/32/75695_2.png) [@cyclotron3k](https://community.auth0.com/u/cyclotron3k)\
**Post date:** [July 13, 2025, 1:21pm UTC](https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864/3 "2025-07-13T13:21:40Z")

</div>

I’ve been going around and around in circles for hours, trying to fix this same issue. How did you figure it out?!

---

<div class="post-metadata">

**Author:** ![devops19](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/devops19/32/71813_2.png) [@devops19](https://community.auth0.com/u/devops19)\
**Post date:** [July 13, 2025, 3:26pm UTC](https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864/4 "2025-07-13T15:26:29Z")

</div>

Found it on the v4 migration guide, in the id token claims section. Searching the issue kept bringing up issues related to the action but everything I tried that was suggested didn’t work. I knew it had to be related to a v4 change so just dug through the guide and found that bit and that worked.

> <https://github.com/auth0/nextjs-auth0/blob/main/V4_MIGRATION_GUIDE.md#id-token-claims>

---

<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:** [July 27, 2025, 3:27pm UTC](https://community.auth0.com/t/custom-claims-in-action-no-longer-working-after-migrating-from-v3-8-to-v4-8/188864/5 "2025-07-27T15:27:23Z")

</div>

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