Skip to content

Starter React project that integrates with Amazon Cognito authentication and S3 bucket hosting

License

Notifications You must be signed in to change notification settings

jjmerri/react-aws-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React AWS Starter

Note: You will need an AWS account to get this project integrated with AWS using AWS Amplify. This tutorial will provision AWS resources that YOU WILL GET CHARGED for if you are not using a Free Tier AWS account!

AWS Amplify is an open source JavaScript library provided by Amazon Web Services that enables developers to build applications with cloud services on web or mobile platforms. This starter project uses the AWS Amplify Command Line Interface to provision hosting and authentication resources in AWS to get a cloud hosted and authentication protected React app up and running.

This app cannot be started until we create /src/aws-exports.js by running amplify init which will be done by following steps below.

Install and Configure the AWS Amplify CLI

Install the AWS Amplify CLI:

npm install -g @aws-amplify/cli

Configure amplify:

amplify configure

Follow the prompts and choose default values. Once complete, initialize amplify by running the following command in the project's root directory :

amplify init

Follow the prompts and choose default options. Put dev as your environment name and make sure to pick javascript as the type of app and react as the framework you are using. After the initialization completes you should be able to install dependencies with npm install and start the app with npm start. Authentication has not yet been configured so you will not be able to register a user, login, or view the auth protected route.

Add Authentication to the Project

Create the auth configurations locally by running the following command in the root directory of the app.

amplify add auth

Choose the default options and then run the following command to provision your resources in the cloud:

amplify push

At this point you can start the app locally by running npm start and you can now register users and see the authentication in action! Continue on to get your app to the cloud!

Add Cloud Hosting

Create cloud hosting configurations locally by running the following command in the root directory of your app:

amplify add hosting

Choose the default options and then publish your changes to AWS by running the following command:

amplify publish

Now you should have a fully functioning app complete with authentication deployed to the cloud!

Check out the app

Try to go to the /user-profile route. If you are not logged in you will get redirected to the login page. Create a user and login and you should be redirected to the /user-profile page which you can now view because you are authenticated.

About

Starter React project that integrates with Amazon Cognito authentication and S3 bucket hosting

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published