Deploy a React Application with AWS
Last Updated :
25 Oct, 2023
AWS is a subsidiary of Amazon & offers a broad range of cloud computing services, which means services using their infrastructure which is hosted on various data centers all over the world which we can rent to run our own solutions.
In this article, we will learn how to deploy a React application using AWS. First, we will build a React Application using create-react-app. Then, we will deploy it in Amazon S3.
Steps to Create a React Application
Step 1Step 2: Check whether Node.js is installed in your system.
node --version

Step 2: Now, write the following command to create a new react app using create-react-app.
npx create-react-app my-web-app
.png)
.png)
Step3: “cd my-web-app” command will help to navigate to the newly created directory “my-web-app”. Now write “npm start” command to start the local server.
.png)
Step4: Now, the React app is running at "http://localhost:3000/". Type the link in the browser to open the React app.
Running on Local Server (localhost:3000)So, your react application is ready!!!
Step5: Create a build of this application. Write “npm run build” to build or compile the project's source code. It will create a “build” directory that contains some static files.
.png)
Steps to deploy the React Application in Amazon S3
Step1 (Login to AWS Console): Go to https://console.aws.amazon.com and Login to your AWS Console.
Step2 (Create Bucket): Search S3 Bucket page and go there. Click upon the “Create Bucket” button.

Creating S3 BucketStep3 (Update the Public Access Permission): By default, the “Block all public access” field will be checked. This should be unchecked, else the bucket will be private and nobody can access our website.
-(1).png)
Now, at the end you see the “Create Bucket” button, click upon that and your bucket will be created. It will look like this.
S3 Bucket (gfg-react-app)Step4 (Add Bucket Policy): Go to “Permissions” tab and click upon “Edit” button in Bucket Policy section. Now, click upon the “Policy Generator” button.

You can create a policy here. Select Type of Policy as “S3 Bucket Policy”. In Principal, write “*”. In Actions, select “getObject” action. In ARN, copy your bucket ARN and click upon “Add Statement” button. A new button “Generate Policy” will be visible. Clicking upon that button will generate your required policy.
AWS Policy Generator
XML
{
"Id": "Policy1694774324793",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1694774318358",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::gfg-react-app/*",
"Principal": "*"
}
]
}
Now, add this generated Bucket Policy in Bucket Policy section. This allows everyone to access the S3 objects using the S3 website endpoint.
Bucket PolicyStep5 (Upload files): Now, come to “Objects” tab and upload all the files present in the “build” directory.
S3 Bucket (gfg-react-app)Step6 (Static Site Hosting): Now, go to “Properties” tab and at the end, you can find “Static Website Hosting”. Edit it like the pictures given below and Save changes.

Static Website Hosting
Congrats!!! Your React Application is hosted successfully in Amazon S3 bucket.
Running on Amazon S3 Bucket
Similar Reads
Deploy a Spring Boot Application with AWS
A spring boot application is a Java-based web application that is built using the Spring Boot framework. Spring Boot is a project designed to simplify the development and deployment of production-ready Java applications.Creating a Spring Boot Project with Spring Initializr: Step-by-Step GuideNote :
5 min read
Deploy a Node.js Application with Azure
Deploying a Node.js application on Azure, a prominent cloud computing platform, has become a seamless process, thanks to its user-friendly interface and integration capabilities. This guide aims to walk you through deploying a Node.js application on Azure using the Azure portal. We will cover essent
4 min read
How to Deploy Django Application in AWS EC2?
In this article, we will study how we can deploy our existing Django web application to Windows Server in AWS EC2. We will also see how to use the public IP of the EC2 instance to access the Django application. For this article, you should know about setting up EC2 in AWS. We will see how to deploy
3 min read
How To Deploy Python Application In AWS?
In this article, we will explore how one as a Python developer can deploy the application by harnessing the capabilities of AWS. AWS, a leading cloud computing platform, offers a wide range of services to help developers build, deploy, and manage applications at scale EC2. It provides scalable compu
4 min read
Deploying Scalable Applications with Azure
In modern software development, deploying a scalable application is an important task. With the increase in the number of users, the applications have to handle a large user database, for this, they require a robust infrastructure that is also scalable which will ensure seamless performance and reli
7 min read
How to Deploy Django Application in AWS Lambda?
Pre-requisite: AWS , Python Django is a Python web framework that makes it easy to build web applications quickly and securely. It has a large and helpful community that provides support and contributes to its development. AWS Lambda is a serverless computing platform that runs your code in Docker c
7 min read
How to Deploy a Go Web Application with Docker?
Pre-requisite: Docker A popular containerization tool called Docker enables developers to quickly package programs and their environments, enabling shorter iteration times and greater resource efficiency while delivering the same intended environment each time. A container orchestration tool called
3 min read
Deploying a React Application in Kubernetes
Kubernetes is an open-source free manager for your computer program. These programs can be in the containers. Each container holds a program and everything it needs to run. To Keep track of all these containers that contain your application this is where the Kubernetes role comes in. Kubernetes does
5 min read
Deploying Web Applications On AWS Lightsail
Amazon Web Service offers a service called Lightsail which is used for deploying and managing web applications. It is well suited for small-scale businesses and developers it will scale and manage the application in the cloud. What is Amazon Lightsail?For anyone who needs to develop websites or web
8 min read
Deploy a Microservices Architecture with AWS
In the ever-evolving realm of software program development, embracing revolutionary architectures is pivotal. Microservices, a modern-day technique to utility design, have gained considerable traction attributable to their flexibility, scalability, and resilience. Amazon Web Services (AWS), a main c
6 min read