An article explaining how to integrate AWS Cognito with React for user authentication. Cognito collects a user’s attributes, it enables simple, secure user authentication, authorization and user management for web and mobile apps. By Carlos Zuniga.
In the article you will find:
- Overview of Cognito
- Integration with React
- Setup
- useAuth hook
- Usage
- Secure routing
- Login page
- Using Terraform to provision Cognito
AWS Cognito is a good option when it comes to user authentication and management. It’s specially useful when you are already bought into the AWS ecosystem and it’s also cheaper than some other alternatives.
It’s not too difficult to integrate React and Cognito, however Cognito’s reference documentation for their Javascript/Typescript package lacks some in-depth detail, they also have several seemingly overlapping packages (amplify, @aws-amplify/auth and amazon-cognito-identity-js) that make it hard to pinpoint exactly which one is necessary for Cognito to work. Amazon also tends to push Amplify as a whole for the auth solution when it’s not really necessary to add all that code to your app. Excellent read!
[Read More]