# Auth0 Permission Check with NextJS

**URL:** <https://community.auth0.com/t/auth0-permission-check-with-nextjs/82175>\
**Category:** Get Help\
**Tags:** permissions, nextjs, login, auth0\
**Created:** [April 21, 2022, 10:35pm UTC](https://community.auth0.com/t/auth0-permission-check-with-nextjs/82175 "2022-04-21T22:35:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ar4891](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ar4891](https://community.auth0.com/u/ar4891)\
**Post date:** [April 21, 2022, 10:35pm UTC](https://community.auth0.com/t/auth0-permission-check-with-nextjs/82175/1 "2022-04-21T22:35:13Z")

</div>

I use React + Auth0 + NextJS for server rendering. Currently I do

```auto
export const getServerSideProps = withPageAuthRequired({
  getServerSideProps: async (context: GetServerSidePropsContext) => {
    return {} ;// Return needed server side props
  },
});

```

As you may already know **withPageAuthRequired** just checks for authentication not authorization such as, does user have specific roles or not.  
How can I check for authorization of a specific user, if user has specific roles or not?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [April 22, 2022, 12:44am UTC](https://community.auth0.com/t/auth0-permission-check-with-nextjs/82175/5 "2022-04-22T00:44:53Z")

</div>

Hi there @ar4891 welcome to the community!

> [@ar4891](#):
>
> How can I check for authorization of a specific user, if user has specific roles or not?

While I’m not super familiar with NextJS, typically roles are added to an Access Token and are utilized that way - The following resources may be of help:

> <https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#access-an-external-api-from-an-api-route>

> **[How to Authenticate with Next.js and Auth0: A Guide for Every Deployment Model](https://auth0.com/blog/ultimate-guide-nextjs-authentication-auth0/)**
>
> Learn how and where to authenticate your user in the different deployment models that exist for Next.js. This guide explores the Custom S...

Regarding adding the roles as a custom claim to an Access Token, please see:

> [@Setting a user role in an action will not update the permissions in the access token](https://community.auth0.com/t/setting-a-user-role-in-an-action-will-not-update-the-permissions-in-the-access-token/70867/2):
>
> Hi @kl.auth Welcome to Auth0 Community !!! Don’t use Management API call for this. You can add a custom roles claim in a [post-login action](https://auth0.com/docs/actions/triggers/post-login) like this: /\*\* \* @param {Event} event - Details about the user and the context in which they are logging in. \* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login. \*/ exports.onExecutePostLogin = async (event, api) =\> { const namespace = 'https://my-app.example.com'; if (event.authorization) { api…

Hope this helps!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [May 25, 2022, 11:06pm UTC](https://community.auth0.com/t/auth0-permission-check-with-nextjs/82175/6 "2022-05-25T23:06:38Z")

</div>


