---
title: "Discussion on \"Build an Authentication System with AWS Amplify, Cognito and React\" | Hashnode"
description: "Discussion on \"Build an Authentication System with AWS Amplify, Cognito and React\". Building a simple authentication has never been easier with the help of AWS Amplify. In this step-by-step tutorial, let's authenticate users by integrating AWS Amplify (and Cognito) in a React app.\nPrerequisites\n\nNode.js and npm installed in machine\n..."
url: "https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Build an Authentication System with AWS Amplify, Cognito and React](https://blog.lo-victoria.com/build-an-authentication-system-with-aws-amplify-cognito-and-react?utm_source=hashnode&utm_medium=feed)

Building a simple authentication has never been easier with the help of AWS Amplify. In this step-by-step tutorial, let's authenticate users by integrating AWS Amplify (and Cognito) in a React app. Prerequisites Node.js and npm installed in machine ...

Jun 10, 2021 · 6 min read · blog.lo-victoria.com  
Updated Dec 31, 2022  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#authentication](https://hashnode.com/tag/authentication)
-   [#aws](https://hashnode.com/tag/aws)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#beginners](https://hashnode.com/tag/beginners)

## Written by

[Victoria Lo](https://hashnode.com/@victoria)

@victoria · Singapore

  
[View profile](https://hashnode.com/@victoria)

A nerd in books, tea, games and software.

I'm a solutions engineer lead, GitHub Star, Director of WomenDevsSG, and co founder of ragTech. I work at the intersection of tech, systems, and leadership, and this blog is where I share my journey through all three. Expect honest reflections, real experiences, and thoughts that are still forming rather than polished career advice.

## Responses 11

Markdown supported · ⌘↵ to post

[Kushang N](https://hashnode.com/@kushang24)

[Jan 23, 2024](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/65af8315928a87b6626b5a75)

Really great walkthrough of amplify auth. Loved the article!!!

[Victoria Lo](https://hashnode.com/@victoria)

[Jan 27, 2024](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/65af8315928a87b6626b5a75#reply-65b508b69a0c2e9f832ffaae)

Thank you [Kushang N](https://hashnode.com/@kushang24) :)

[Hari Krishnan Murthy](https://hashnode.com/@harikrishnanmurthy)

[Apr 5, 2023](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/642d07f2480bd310626c1203)

Hey there,

So I was trying to improvise on this amplify authentication by adding a custom attribute to the sign up screen. After fiddling around for a couple of weeks and skimming tons of articles on the internet, I found a way to do this.

1) After executing

```
amplify add auth
```

we need to execute the following command:

```
amplify override auth
```

This will create a new file called **override.ts** in the amplify folder. You then paste the following snippet within the enclosing function in this file:

```
    const myCustomAttribute = {
        attributeDataType: 'String',
        developerOnlyAttribute: false,
        mutable: true,
        name: '<name of your attribute for eg registration_code>',
        required: false,
      }
      resources.userPool.schema = [
        ...(resources.userPool.schema as any[]), // Carry over existing attributes (example: email)
        myCustomAttribute,
      ]
```

2) Execute

```
amplify push
```

3) Once push is done, you should be able to see your new attribute under "custom attributes" in the AWS cognito pool.

4) In your react code, you modify the withAuthenticator section like below:

```
export default withAuthenticator(PatientList, {
  formFields: formFields,
  signUpAttributes:['email', 'custom:<your attribute same as in override.ts>'],
  components: {
    SignIn: {
      Header: Header,
    }
  }
});
```

where formFields should look like:

```
const formFields = {
  signUp: {
    username: {
      order: 1,
    },
    password: {
      order: 2,
    },
    confirm_password: {
      order: 3,
    },
    email: {
      order: 4,
    },
    'custom:<your attribute name as in override.ts>': {
      order: 5,
      label: "<custom_label_name>"
    },
  },
};
```

Hope this helps someone.

[Victoria Lo](https://hashnode.com/@victoria)

[Apr 5, 2023](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/642d07f2480bd310626c1203#reply-642d2c22a810a0168a64b95d)

Thanks [Hari Krishnan Murthy](https://hashnode.com/@harikrishnanmurthy)! This is awesome!

[Hari Krishnan Murthy](https://hashnode.com/@harikrishnanmurthy)

[Dec 30, 2022](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/63aeba5a2381e73bbf93bba7)

Hey Victoria, Thanks a ton for the article. I followed it to the 'T' and it almost got me there. I had to do minor tweaks to get this to work for the latest version aws amplify.

I am listing the tweaks I had to do to get this working in my case. Hopefully, it helps someone who is looking for leads like me:

1) I had to wrap Amplify inside {} to get it to work. Else I got an import error on app startup

```
import { Amplify } from 'aws-amplify';
```

2) I had to import the css explicitly since it is no longer part of the amplify dist I suppose:

```
import '@aws-amplify/ui-react/styles.css';
```

3) AmplifySignOut is no longer supported. I had to use Authenticator and wrap the code within { signOut, user }. For example:

```
return (
    <Authenticator>
      {({ signOut, user }) => (
        <div className="App">
          <Alert variant="success">
            <Alert.Heading>Hey, {user.username}</Alert.Heading>
            <p>
              Thanks for using abcdef &#10084;
            </p>
            <hr />
            <p className="mb-0">
              Would you like to sign out from this device?
            </p>
          </Alert>
          <button className="btn btn-info mr-2" onClick={signOut}>Sign out</button>
        </div>
      )}
    </Authenticator>
  );
```

Other than these, the tutorial worked like a charm. Keep rocking :)

[Victoria Lo](https://hashnode.com/@victoria)

[Dec 31, 2022](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/63aeba5a2381e73bbf93bba7#reply-63af9d0a42ec5647dfa0248b)

Wow [Hari Krishnan Murthy](https://hashnode.com/@harikrishnanmurthy)! I should be thanking you 😊 Thanks so much! I'll update the article~

[Idris Olubisi](https://hashnode.com/@olanetsoft)

[Jun 12, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c49b20a25fa357af840fb8)

Thanks for sharing ❤️

[SeanKPS](https://hashnode.com/@seankps)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c35534a25fa357af83f8f1)

You mentioned a verification code. Has configuring this part of the process gotten any simpler? So you can use verification link for example. I really like this font

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c35534a25fa357af83f8f1#reply-60c36356a25fa357af83faf1)

Yes, you can choose to send a verification to the user's email or a link. It's up to you. You can check out the official docs for details on how to configure :)

[Toni Tesori](https://hashnode.com/@ttesori)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c3519b1e145957d5af6f6a)

Fantastic - I just learned about this system in a talk at the Women Who Code conference; can't wait to use your guide to build it myself!

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c3519b1e145957d5af6f6a#reply-60c363781e145957d5af72c4)

Thanks for reading! Glad this article will be useful for you!

[Tapas Adhikary](https://hashnode.com/@atapas)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c34c9c1e145957d5af6eaf)

Thanks for sharing [Victoria Lo](https://hashnode.com/@victoria).

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c34c9c1e145957d5af6eaf#reply-60c36380a25fa357af83fb09)

No problem Tapas :)

[Catalin Pit](https://hashnode.com/@Catalinpit)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2fc2a1e145957d5af6632)

How did you find AWS Amplify? I keep saying I'll give it a go but I keep putting it off.

Great article by the way! 🔥

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2fc2a1e145957d5af6632#reply-60c36314a25fa357af83fae1)

Amplify is super easy and fast to set up and learn! I'm sure you'll pick it up in no time! Thanks for reading :)

[Neha Badiani](https://hashnode.com/@nehabadiani)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2f370a25fa357af83ed45)

This is super useful! I'll be using it, thank you!!

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2f370a25fa357af83ed45#reply-60c363b81e145957d5af72c8)

Thanks Neha, glad to hear it's useful for you :)

[Jarrod Watts](https://hashnode.com/@JarrodWatts)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2b5a9a25fa357af83ea1d)

Great Article Victoria, thanks for sharing :-)

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2b5a9a25fa357af83ea1d#reply-60c363a3a25fa357af83fb17)

My pleasure, Jarrod! Thanks for the read :)

[Savio Martin](https://hashnode.com/@saviomartin)

[Jun 10, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2310c1e145957d5af5b18)

Always amazing! Thanks for the super great content! Will be useful a lot!

[Victoria Lo](https://hashnode.com/@victoria)

[Jun 11, 2021](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/60c2310c1e145957d5af5b18#reply-60c36391a25fa357af83fb0d)

You're welcome Savio! Thanks for reading :)
