# Adding claims via nextjs / handleProfile

**URL:** <https://community.auth0.com/t/adding-claims-via-nextjs-handleprofile/71188>\
**Category:** Get Help\
**Tags:** nextjs\
**Created:** [October 12, 2021, 2:04pm UTC](https://community.auth0.com/t/adding-claims-via-nextjs-handleprofile/71188 "2021-10-12T14:04:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonkcinema](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonkcinema/32/32285_2.png) [@jonkcinema](https://community.auth0.com/u/jonkcinema)\
**Post date:** [October 12, 2021, 2:04pm UTC](https://community.auth0.com/t/adding-claims-via-nextjs-handleprofile/71188/1 "2021-10-12T14:04:38Z")

</div>

(I am using the @auth0/nextjs-auth0 SDK.)

I am trying to add some custom claims to my user session, and so am overriding the `profile` handler in `handleAuth`, in my `/pages/api/auth/[...auth0].js` file:

```auto
import { handleAuth, handleProfile } from '@auth0/nextjs-auth0';

const afterRefresh = async (req, res, session) => {
  console.log('in afterRefresh')
  console.log(session)
}

export default handleAuth({
  async profile(req, res) {
    try {
      await handleProfile(req, res, { afterRefresh, refetch: true })
    } catch (error) {
      res.status(error.status || 500).end(error.message)
    }
  }
})

```

However, my afterRefresh function never seems to be called, even when I pass `refetch: true`.

Has anyone had success with this? Any tips?

Thanks,  
-Jon

---

<div class="post-metadata">

**Author:** ![jonkcinema](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jonkcinema/32/32285_2.png) [@jonkcinema](https://community.auth0.com/u/jonkcinema)\
**Post date:** [October 12, 2021, 2:30pm UTC](https://community.auth0.com/t/adding-claims-via-nextjs-handleprofile/71188/2 "2021-10-12T14:30:38Z")

</div>

Figured out the issue… the argument is afterRefetch, not afterRefresh

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [October 12, 2021, 2:59pm UTC](https://community.auth0.com/t/adding-claims-via-nextjs-handleprofile/71188/3 "2021-10-12T14:59:27Z")

</div>

Perfect! Thanks for sharing that with the rest of community!

---

<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:** [October 27, 2021, 2:59pm UTC](https://community.auth0.com/t/adding-claims-via-nextjs-handleprofile/71188/4 "2021-10-27T14:59:42Z")

</div>

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