Search code examples
reactjsamazon-web-servicesamazon-cognitoaws-amplify

Is there a way to request sign-up redirect in Cognito Hosted UI via Amplify JS SDK with React?


I'm extending the example from the official Amplify docs but the problem is that I'd like a third button for direct redirection to the Hosted UI's Sign Up page:

<div>
  <p>User: {user ? JSON.stringify(user.attributes) : 'None'}</p>
  {user ? (
    <button onClick={() => Auth.signOut()}>Sign Out</button>
  ) : (
    <button onClick={() => Auth.federatedSignIn()}>Sign In</button>
    <button onClick={() => Auth.federatedSignIn(??)}>Sign Up</button>
  )}
</div>

Sadly, I can't find a way to utilize federatedSignIn() to that effect and Amplify API docs don't seem to help either. Any ideas? Cheers


Solution

  • In the end I fell back to using Cognito Hosted UI urls directly. Originally I had avoided this because sometimes during signin, after redirect back to my App the authorization code wasn't exchanged to get a token automatically by Amplify. Now it seems to be working.

    If anybody has other ideas feel free to share