# How to redirect new users to an onboarding page?

**URL:** <https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280>\
**Category:** Get Help\
**Tags:** login-prompt-new-experience, login-experience\
**Created:** [August 9, 2023, 5:59pm UTC](https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280 "2023-08-09T17:59:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff14](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff14/32/49749_2.png) [@jeff14](https://community.auth0.com/u/jeff14)\
**Post date:** [August 9, 2023, 5:59pm UTC](https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280/1 "2023-08-09T17:59:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [August 9, 2023, 10:07pm UTC](https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280/3 "2023-08-09T22:07:15Z")

</div>

Hi @jeff14,

Welcome to the Auth0 Community!

To redirect your users to your preferred page, you will need to make sure of the following:

1. The URL is added to your application’s **Allowed Callback URLs** list.
2. The URL is specified in your `redirect_uri` query parameter in your login request (`/authorize`)

Using the Next.js SDK, there are 2 places where you can set this value.

By default, you can set this in the `returnTo` property in your [Login handler’s Login Options](https://auth0.github.io/nextjs-auth0/interfaces/handlers_login.LoginOptions.html#returnTo).

You could also set this in the `redirectUri` property in your [Callback handler’s Callback Options](https://auth0.github.io/nextjs-auth0/interfaces/handlers_callback.CallbackOptions.html#redirectUri). 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!

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![jeff14](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff14/32/49749_2.png) [@jeff14](https://community.auth0.com/u/jeff14)\
**Post date:** [August 10, 2023, 12:16am UTC](https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280/4 "2023-08-10T00:16:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [August 10, 2023, 4:41pm UTC](https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280/5 "2023-08-10T16:41:01Z")

</div>

Hi @jeff14,

Thanks for following up.

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](https://auth0.com/docs/customize/rules/context-object#:~:text=context-,.,-stats) for more information.

For this to work, I recommend calling the Management API’s [Get a user endpoint](https://auth0.com/docs/api/management/v2/users/get-users-by-id) 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.

I hope this helps!

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 24, 2023, 4:41pm UTC](https://community.auth0.com/t/how-to-redirect-new-users-to-an-onboarding-page/113280/6 "2023-08-24T16:41:39Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
