What is the best way to 'extend' the ProtectedRoute example to also include a check for specific user roles?

I’ve been following the documentation for the use of @auth0/auth0-react and it’s been going well, but I had a question:

Is it possible to also add a <ProtectedRoute> that checks for a specifc role that the user is assigned to?

I’ve got an Admin role in my application and I’m wanting to also make a guard that keeps people from accessing specific routes (I’m using react-router-dom) unless they’re assigned to the Admin role.

I saw that withAuthenticationRequired has a claimCheck option, but I didn’t know if I could use that to check for the value of a claim (I’ve got a rule that adds Roles as a claim to the token) or just the existence of the claim itself.

Thanks in advance for any help, I’d really appreciate it! Also, thanks for all the hard work in building this library and awesome service. :slight_smile:

1 Like