Hi, I’m new to using Auth0 sos still trying to get an understanding of how things work.
What i’m wanting to do is conditional checks client-side which will show/hide certain content depending on authenticated user roles.
All users will either have a role of default or admin set. If a users role is admin, then the conditional will pass using something like the below.
Is there away to get role data set on a user through useUser? if not, is there a different or better way to achieve what i’m trying to do?
This is for a Nextjs project.
const { isLoading, error, user } = useUser();
if (isLoading) return <div>Loading...</div>;
if (error) return <div>{error.message}</div>;
if (user.roles.includes('admin')) {
console.log('User is an admin.');
// Perform admin-specific actions here
}