Pass authorizationParams to loginWithRedirect to Direct Users to Auth0 Sign Up

InstructorWill Johnson

Share this video with your friends

Send Tweet

Create a signup-button.js file under the src/components/buttons folder

Add the following code:

import { useAuth0 } from "@auth0/auth0-react";
import React from "react";

export const SignupButton = () => {
  const { loginWithRedirect } = useAuth0();

  const handleSignUp = async () => {
    await loginWithRedirect({
      appState: {
        returnTo: "/profile",
      },
      authorizationParams: {
        screen_hint: "signup",
      },
    });
  };

  return (
    <button className="button__sign-up" onClick={handleSignUp}>
      Sign Up
    </button>
  );
};

Adding authorizationParams to the loginWithRedirect() configuration object with the screen_hint property and a value of signup will take users from your React application to the sign-up page.