Yes, this is possible. To retrieve the user roles in non-React functions, you can call the getIdTokenClaims() function inside a React component wrapped in Auth0Provider. This way, the token is decoded with its claims cached and can be accessed later in non-React functions.