I’m using Auth0 with a React single-page application.
I need to implement authorization logic at the frontend level — for example, hiding certain routes or UI elements depending on what the user is allowed to do (e.g., only admins can access an admin dashboard).
I see a few possible approaches:
Include user roles as a custom claim in the ID or access token via an Auth0 Post-Login Action (I’ve read that Auth0 provides this option). Then, check the roles in the React app.
Instead of roles, rely on the permissions claim that Auth0 automatically adds to the access token when RBAC is enabled (“Add permissions in the Access Token” option).
Dynamically retrieve roles or permissions from the Auth0 Management API (though I know this isn’t recommended directly from the browser).
I’ve read that tokens generally shouldn’t expose too much authorization data, and I’m trying to understand what’s considered a best practice for SPAs.
For frontend-only route visibility (not API enforcement), should I rely on roles in the token (via a Post-Login Action), on permissions in the token (via RBAC), or is there a more secure/recommended way to handle client-side authorization in a React SPA using Auth0?
Thanks!