Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auth0 and react, redirect user to signup page

Tags:

reactjs

auth0

I am using Auth0 for my authentication on a React + C# asp.net core page.

I would like the users to click "Sign up" and it direct them to the Auth0 Universal Sign up page. I'm able to direct users to the Login Page with this code:

await loginWithRedirect({
    appState: { targetUrl: location.pathname || window.location.pathname },
});

Using the example react-auth0-spa.js and @auth0/auth0-spa-js library.

However, I can't see any examples online on how to direct a user directly to the sign up (not login) page.

like image 421
Michael Avatar asked Oct 24 '25 08:10

Michael


2 Answers

Looks like they've changed it again (as of 07/05/2023). To navigate directly to the Sign Up portion of the login you need to use the authorizationParams.

loginWithRedirect({
  authorizationParams: {
     'screen_hint': 'signup',
  }});

Credits to this article.

like image 187
Madison Lai Avatar answered Oct 26 '25 23:10

Madison Lai


The two prior answers refer to v1 and v2 of our SDKs respectively. We introduced new parameters as authorizationParams in v2 in 2022 in order to structure these better and allow room for improvements like your own custom parameters. This breaking change is documented in our version migration guide.

Expanding a bit on the other answers, from the v2 docs:

await client.loginWithRedirect({
  appState: {
    key: value // state to restore when getting redirected back
  },
  authorizationParams: {
    screen_hint: 'signup',
    any_custom_property: 'value'
  }
});
like image 25
wadenick Avatar answered Oct 26 '25 23:10

wadenick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!