# How to redirect to a new page within a rule?

**URL:** <https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029>\
**Category:** Get Help\
**Tags:** rules, redirect-rules\
**Created:** [March 25, 2021, 2:00am UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029 "2021-03-25T02:00:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![victor-wei126](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/victor-wei126/32/28140_2.png) [@victor-wei126](https://community.auth0.com/u/victor-wei126)\
**Post date:** [March 25, 2021, 2:00am UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/1 "2021-03-25T02:00:04Z")

</div>

Here is the scenario: New users who signup will be redirected to a signup form to collect additional info. After they submit that, they are redirected to the dashboard. Currently, I have it set up so that once the user logins, the redirectUri for auth0 is set to the signup form. However, I need to change this so that only first time users will be redirected to that form.

I am planning to use rules to implement this, and have read some of the documentation. However, I am confused. So far, I have set up context.redirect url.

The url I wish to redirect to is: [http://localhost:3000/signup](http://localhost:3000/signup). However, Auth0 adds a state parameter field to the url, and this messes up the page and doesn’t load it properly. How do I fix this?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 25, 2021, 11:39am UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/2 "2021-03-25T11:39:27Z")

</div>

Hey there!

Here’s our doc on how to redirect users using rules:

> **[Redirect Users from Within Rules](https://auth0.com/docs/customize/rules/redirect-users)**
>
> Learn how to customize authentication flows by redirecting users using rules. Example areas that can be customized include MFA, privacy policy acceptance, and gathering user data.

---

<div class="post-metadata">

**Author:** ![victor-wei126](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/victor-wei126/32/28140_2.png) [@victor-wei126](https://community.auth0.com/u/victor-wei126)\
**Post date:** [March 25, 2021, 1:25pm UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/3 "2021-03-25T13:25:21Z")

</div>

Hi Konrad, I have already read this doc as stated in my message, but I am confused about what the state parameter does in the url and how to deal with that?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 25, 2021, 2:29pm UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/4 "2021-03-25T14:29:18Z")

</div>

Gotchya!

- Here’s more on state:

> **[Prevent Attacks and Redirect Users with OAuth 2.0 State Parameters](https://auth0.com/docs/secure/attack-protection/state-parameters)**
>
> Describes how to use the state parameter in authentication requests to help prevent CSRF attacks and restore state

- and here on redirecting users with state parameters:

> [@Redirecting Users with State Parameters](https://community.auth0.com/t/redirecting-users-with-state-parameters/39520):
>
> Hello, I’m trying to redirect my users after login/signup in a React app. I’ve been reading about how to do that using a state param in the authentication request using a nonce per these docs. ([Redirect Users](https://auth0.com/docs/protocols/oauth2/redirect-users)) My question is concerning this quote: As part of the callback processing and response validation Where is this callback processing done? I have a callback handler but no information is passed to it. So, how do I validate a response? Where is this response data that I can evaluat…

---

<div class="post-metadata">

**Author:** ![victor-wei126](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/victor-wei126/32/28140_2.png) [@victor-wei126](https://community.auth0.com/u/victor-wei126)\
**Post date:** [March 25, 2021, 7:41pm UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/5 "2021-03-25T19:41:28Z")

</div>

Okay thank you for the article. After reading it, I’m not so sure I need a rule to do this, since this seems much more complex.

My workflow is this. The user clicks sign up (on the auth0 signup form) → auth0 authenticates the user using IdP → the user is now sent back to my application.

However, depending on whether the user is new or not, they will be redirected to a different page within my application. If they are new, they will be sent to a signup form. If not, they are sent to the regular dashboard.

I can easily implement this in React by using react-router. However, the key information I need is if the user is new or not. Currently, the only way I can think of doing this is by using context.stats.loginscount, and thus I have resorted to using it in a rule. Do I need a rule or is there another way?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 26, 2021, 7:19am UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/6 "2021-03-26T07:19:36Z")

</div>

I would say the approach you mentioned is the best way as one of our employees also recommended that method here:

> [@How to tell if a user is logged in for the first time?](https://community.auth0.com/t/how-to-tell-if-a-user-is-logged-in-for-the-first-time/28813):
>
> Hello, We would like to show some language to a user if they have just created their account and logged in for the first time. Is there a way for us to tell if a user is logging in for the first time during or after the auth callback? Thanks, Paul

---

<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:** [April 10, 2021, 7:20am UTC](https://community.auth0.com/t/how-to-redirect-to-a-new-page-within-a-rule/60029/7 "2021-04-10T07:20:04Z")

</div>

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