Auth0 Home Blog Docs

How to handle authorization based on roles in a React application

I’ve been working with the React SDK Quickstart guide here: This guide shows you how to create a PrivateRoute component that directs the user to log in if they aren’t authenticated. It will display the desired component if a user is authenticated.

This is what I’m trying to figure out:
I currently have my Auth0 API returning user roles in the id token. How can I modify my PrivateRoute to only display a component if they also have the proper role? Can I reuse this PrivateRoute to render components for multiple roles? Or would I need to create multiple, for example an AdminPrivateRoute or RegularUserPrivateRoute?

Any guidance would be appreciated. Thanks.