When new users log in for the first time, they should be taken to an onboarding page at MYDOMAIN.com/onboarding. Returning users go to MYDOMAIN.com instead. Should this be done using Auth0 actions? Or should it be specified in the handleCallback?
I’m using Next.js with a route at /api/auth/[...auth0].js where handleCallback is defined.
You could also set this in the redirectUri property in your Callback handler’s Callback Options. If you do choose this approach, note that it will override the value set in your returnTo property.
Please let us know if you have any additional questions!
Thank you! I was wondering if I could somehow access the context.stats object from the callback handler? I need a way to distinguish between new users and returning users.
Unfortunately, the context.stats property cannot be called in the Next.js SDK. For clarity, the context.stats is an object only callable inside of an Auth0 Rule. See Context Object Properties in Rules for more information.
For this to work, I recommend calling the Management API’s Get a user endpoint and filtering for the user’s logins_count attribute.
Alternatively, you could append the user’s logins_count as a custom claim in the access token and proceed with your logic that way.