---
title: "Comment by Hari Krishnan Murthy on \"Build an Authentication System with AWS Amplify, Cognito and React\" | Hashnode"
description: "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"
url: "https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e/comment/642d07f2480bd310626c1203"
---

[Discussion](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e)

Comment [Build an Authentication System with AWS Amplify, Cognito and React](https://hashnode.com/posts/build-an-authentication-system-with-aws-amplify-cognito-and-react/60c228941e145957d5af5a4e)

[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!
