Amplify UI

Configuration

How to setup and configure your Authenticator component.

Wait!

Did you follow the quick start instructions to set up the Authenticator first?

Initial State

By default, unauthenticated users are redirected to the Sign In flow. You can explicitly redirect to Sign Up or Forgot Password:

Login Mechanisms

Zero Configuration

The Authenticator automatically infers loginMechanisms from amplify pull, but can be explicitly defined as seen below.

By default, the Authenticator creates new users in the Amazon Cognito UserPool based on a unique username using Auth.signUp.

You can provide an alternative username such as email or phone_number.

Note: A username, email, or phone_number value is required for Cognito User Pools.

export default function App() {
  return (
<Authenticator loginMechanisms={['username']}>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }
export default function App() {
  return (
<Authenticator loginMechanisms={['email']}>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }
export default function App() {
  return (
<Authenticator loginMechanisms={['phone_number']}>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }

Sign Up Attributes

Zero Configuration

The Authenticator automatically infers signUpAttributes from amplify pull, but can be explicitly defined as seen below.

The Authenticator automatically renders most Cognito User Pools attributes, with the exception of address, gender, locale, picture, updated_at, and zoneinfo. Because these are often app-specific, they can be customized via Sign Up fields.

By default, the Authenticator will still require any attributes required for verification, such as email, even if signUpAttributes is empty:

export default function App() {
  return (
<Authenticator signUpAttributes={[]}>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }
export default function App() {
  return (
<Authenticator signUpAttributes={[
'address',
'birthdate',
'email',
'family_name',
'gender',
'given_name',
'locale',
'middle_name',
'name',
'nickname',
'phone_number',
'picture',
'preferred_username',
'profile',
'updated_at',
'website',
'zoneinfo',
]}>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }

Social Providers

Zero Configuration

The Authenticator automatically infers socialProviders from amplify pull, but can be explicitly defined as seen below.

For your configured social providers, you can also provide amazon, facebook, or google:

export default function App() {
  return (
<Authenticator socialProviders={['amazon', 'apple', 'facebook', 'google']}>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }

Step by step video on setting up social providers.

Variation

The Authenticator has multiple variations to meet the needs of your application.

By default, the Authenticator will render as a centered card within the container:

export default function App() {
  return (
<Authenticator>
{({ signOut, user }) => ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> )} </Authenticator> ); }

Hide Sign Up

The Authenticator has an option to hide the sign up page including the Create Account tab.

Amplify.configure(awsExports);

const formFields = {
signIn: { username: { placeholder: 'Enter your cool email', }, }, confirmVerifyUser: { confirmation_code: { label: 'New Label', placeholder: 'Enter your Confirmation Code:', isRequired: false, }, }, }; const components = { VerifyUser: { Header() { const { tokens } = useTheme(); return ( <Heading padding={`${tokens.space.xl} 0 0 ${tokens.space.xl}`} level={3} > Enter Information: </Heading> ); }, Footer() { return <Text>Footer Information</Text>; }, }, ConfirmVerifyUser: { Header() { const { tokens } = useTheme(); return ( <Heading padding={`${tokens.space.xl} 0 0 ${tokens.space.xl}`} level={3} > Enter Information: </Heading> ); }, Footer() { return <Text>Footer Information</Text>; }, }, }; export default function App() { return ( <Authenticator formFields={formFields} components={components} hideSignUp={true} > {({ signOut, user }) => { return ( <main> <h1>Hello {user.username}</h1> <button onClick={signOut}>Sign out</button> </main> ); }} </Authenticator> ); }

Amplify open source software, documentation and community are supported by Amazon Web Services.

© 2024 Amazon Web Services, Inc. and its affiliates. All rights reserved. View the site terms and privacy policy.

Flutter and the related logo are trademarks of Google LLC. We are not endorsed by or affiliated with Google LLC.