By using AWS re:Post, you agree to the Terms of Use

Redirect after login with aws-amplify/ui-angular 2.0


Hi. I have a Angular application and I like to use the new Authenticator IU compoment. The sample code only show a text message.

    <h1>Welcome {{ user.username }}!</h1>
    <button (click)="signOut()">Sign Out</button>

I need to redirect from the login page to the root site. With the old version of the UI components I used "onAuthUIStateChange", but looks like no longer works on aws-amplify/ui-angular 2.0

  ngOnInit(): void {
    onAuthUIStateChange((authState, authData) => {
      this.user = authData as CognitoUserInterface;
      if (authState === AuthState.SignedIn) {
        console.log("user successfully signed in!");
        console.log("user data: ", authData);
      } else {
        console.log("Status: ", authState);

What is the correct way to redirect after login on an Angular application with aws-amplify/ui-angular 2.0?

asked 9 months ago26 views