User attributes
Amplify Auth stores user profile information in user attributes. When the default method for user sign-in, Amplify Auth will automatically configure an email
or phone_number
attribute that is required for sign-in.
To extend a user profile beyond the default email
or phone_number
attribute that is automatically configured when specified in your auth resource's loginWith
property, you can configure attributes with the userAttributes
property:
import { defineAuth } from "@aws-amplify/backend"
export const auth = defineAuth({ loginWith: { // this configures a required "email" attribute email: true, },})
User attributes are defined as Cognito Standard Attributes. Attributes can be configured to be required for user sign-up in addition to whether the values are mutable. When configuring your resource to allow your users to login with email
, an email must be specified for user sign-up and cannot be changed later. However additional attributes can be configured to be optional, and mutable after sign-up.
In addition to the provided standard attributes, you can configure Custom Attributes. These are attributes that are typically unique to your use case, such as a tenant ID. Currently Amplify Auth does not support custom attributes in the userAttributes
property, however you can configure your auth resource to accept custom attributes using the AWS Cloud Development Kit (AWS CDK).