Customizing the authentication experience of Amplify’s withAuthenticator.

Cory Schimmoeller
Feb 28 · 4 min read

Note: This article builds off of my first article, but if you’re already familiar with AWS Amplify you should be able to follow along.

When we left off, we implemented authentication into our app using aws-amplify-react’s withAuthenticator component. The result of this is that our app now has some basic login, register, and reset password screens.

New Account
Reset Password

You’re probably going to want to change up these screens up, unless your app happens to use the same white and orange branding.

When I saw these screens, the first thing I wanted to change were the attributes required for new users. I want the user to enter their name so that the app can greet them when they login. I also don’t need to get a user’s phone number.

To make these changes we will first need to run

When prompted select ‘No, I will set up my own configuration’, and keep on pressing enter to select the default value for each option. When asked ‘Do you want to specify the user attributes this app can read and write?’ say yes. From that list select the attributes that you want a user to enter on sign-up. For the purposes of this example I chose email and name.

After this you will have to run

to save your changes in the cloud.

If you run your app you will noticed that the registered screen has not changed. In order to change the register screen you will have to add a parameter to withAuthenticator.

Now we can see the name field added to our registration screen.

Next I wanted to add the ability of a user to login using their Google account. First we will have to create a Google Web Client ID. In order to complete this process we will have to run ‘amplify update auth’ again. This time you will want to answer yes when asked if you want to enable 3rd party authentication. Selected Google when you’re shown the list of providers. Paste in the Web Client ID when prompted. Now you run ‘amplify push’ again, but if you run your app you’ll see that, just like before, your login screen hasn’t been updated.

In order to add the Google sign in button you will have add the following lines in index.js .

Once you’ve added all these elements you will likely want to edit the style of the screens. You can change the style of the authentication screens by passing a theme object into withAuthenticator. Theme objects need to adhere to the following template. Attached below is a sample theme.

Another way to customize withAuthenticator is by using custom components. I will not dive into that here because Kyle Galbraith has already written a fantastic article on the topic.

Thanks for reading this article. If you have any questions or if this article helped I’d love to hear from you on twitter.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade