can not import Auth from aws-amplify in Angular even though docs says I can

51 Views Asked by At

I am developing an Angular app with AWS Cognito Authentication using Amplify Angular package. I need to override methods to get callback from signin. I installed the following packages as mentioned in the docs (from my package json):

"@aws-amplify/ui-angular": "^5.0.12"
"aws-amplify": "^6.0.21" 

When I try to import; import { Amplify, Auth } from 'aws-amplify';

it does not let me do it. Gives error on importing:

Module '"aws-amplify"' has no exported member 'Auth'

But in Amplfy Auth docs, there are examples of this usage. What do I miss?

these are the official docs I follow:

https://ui.docs.amplify.aws/angular/connected-components/authenticator https://ui.docs.amplify.aws/angular/connected-components/authenticator/customization

1

There are 1 best solutions below

0
On BEST ANSWER

The doc references you provided appear to be for version 5. However, the latest version v6 allows you to do it shown below.

  1. Add import statement.

    import { Amplify } from 'aws-amplify';
    import { SignUpInput, SignUpOutput, signUp } from 'aws-amplify/auth';
    
  2. Invoke signUp method.

    function doSignup(signUpInput: SignUpInput): Promise<SignUpOutput> {
      .
      .
      .
      return signUp(signUpInput);
    }
    

Also refer to this guide Migrate from Amplify JavaScript v5 to v6 (if required).