Hi Auth0 Community! ![]()
I’m confused about the current best practice for assigning default roles to new users. The documentation seems to point in different directions and I want to make sure I’m following the modern approach.
What I’m Trying to Achieve
-
Assign a default “user” role to every new user on signup
-
Add user roles to JWT tokens for frontend/backend authorization
-
Follow Auth0’s current best practices (not outdated methods)
My Confusion
I’ve found conflicting approaches in the docs:
Approach 1: Management API in Actions (seems outdated?)
-
Assigning Default Roles to a User on Sign up Using Auth0 Actions
-
Uses Management API calls in post-user-registration trigger
-
Problem: Getting “user does not exist” errors in test environment
Approach 2: Custom Claims Only (newer approach?)
-
Add user roles to ID and Access tokens
-
Question: But how do roles get assigned to users in the first place?
Current Issues
When testing Actions with Management API calls:
// This fails in test environment
const existingRoles = await management.users.getRoles({ id: event.user.user_id });
// Error: "The user does not exist" (404)
Questions
-
What’s the current recommended way to assign default roles to new users?
-
Should I use Management API in Actions or is that outdated?
-
Are custom claims the new standard instead of actual Auth0 roles?
-
If using custom claims in the tokens, how do I initially assign roles to users?
-
Is the “user does not exist” error just a test environment limitation?
My Setup
-
Next.js app with @auth0/nextjs-auth0
-
Node.js typescript backend
-
Want both frontend (dashboard protection) and backend (API route protection)
-
Using Triggers
Any guidance on the modern, correct approach would be hugely appreciated! ![]()
Thanks in advance!