Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » AWS/Azure/OpenShift » How to deploy a React Application to AWS S3
  • Wiki in Linux
    How to Use Wiki from Linux Terminal Linux
  • fast user switching in windows 10 1
    Fast user switching: How to create a desktop shortcut in Windows 10 to switch User Accounts Windows
  • screenshot 2020 04 17 at 17.09.01
    How to configure a remote Windows Server to Support Ansible Windows Server
  • aks 1
    Azure Storage: How to create Blob Storage and upload files AWS/Azure/OpenShift
  • Burn ISO on MAC   Proxmox installation
    Create a bootable USB on Mac: Proxmox VE Setup Virtualization
  • update powershell in Windows
    Upgrade PowerShell Core Windows or Mac and Linux System Windows
  • Install SQL Server Management Studio 21 on Windows Server
    Install SQL Server Management Studio 21 on Windows Server Oracle/MSSQL/MySQL
  • Block ZIPRAR Attachments in Outlook 2016 – 2007
    How to Block ZIP/RAR Attachments in Outlook Windows

How to deploy a React Application to AWS S3

Posted on 12/03/202204/05/2024 Dickson Victor By Dickson Victor 2 Comments on How to deploy a React Application to AWS S3
react

In this article, we are going to learn how to deploy a React Application to AWS S3. Simple Storage Service, aka S3, is a block storage service offered by AWS. It is the most commonly used, go-to storage service for AWS users. It provides valuable features like high availability, security, easy connection to AWS services, and hosting static websites. In this tutorial, we will create a sample react app and deploy it as a static website to AWS S3.

There is almost negligible cost to host your websites using S3 website hosting so this can be a great way for you to host your websites for personal work.

Kindly refer to our related AWS guides: Creating IAM Users, Adding MFA and Policies on AWS, how to manage cost with AWS Budgets, how to deploy an Angular App to AWS S3, and how to deploy Dynamic Website to AWS EC2.

Take a look at what we shall be covering in this article: 
- We shall create a simple React App using the "create react app" command
- We shall configure an S3 bucket for static web hosting
- We will be deploying to AWS Cloud

For this tutorial, you should have NodeJS installed on your computer and access to an AWS Account. So, let’s get started.

Creating a ReactJS Application

Go to the CLI in your computer, access the directory where you want to create the react app, and run the following command with any app name of your choice. I have chosen to create a “techdirectarchive-app”

npx create-react-app techdirectarchive-app

This will create a new “techdirectarchive-app” folder in our current directory. Let us move into this directory by running the following command.

 cd techdirectarchive-app

Before we start the default React App. We need to install all the application dependencies by running the following command.

npm install 

Let us now start our React App by running the following command

npm start

This should open a browser tab for you and you should see the default react app running on a localhost port. You can stop the application by pressing Ctrl+C in the terminal.

With this, we have now successfully created our first react app. Let us now access the AWS Console and configure our S3 bucket for website hosting.

Setting up your AWS S3 bucket for website hosting.

– Sign in to the AWS Management Console.
– Navigate to AWS S3 dashboard.

This is the S3 dashboard where you can see the S3 buckets created in your account. Click on Create bucket to create your S3 bucket for website hosting.

1-final-1

The first option when creating the S3 bucket is to give it a name. Note here that your bucket name should be unique across All the S3 buckets in the world, so, if you try to keep common names, you might get some conflicts. See S3 bucket naming rules. Choose a unique name for your bucket. The next option is the AWS region. Choose a region closest to your location.

2

Leave the Object Ownership Option as default.

3

For the Bucket Public Access option, uncheck the default Block all public access and acknowledge the box below as shown in the image. We want our S3 website to be accessible to anyone in the world. SO, it is important that we do not restrict public access.

4-final-1

You can leave all the other parameters as default and click on the Create Bucket button at the end of the page.

You can now see your S3 bucket in the list. Click on the bucket name.

5-final

Go to the properties tab.

6-f

Now scroll down to find the Static website hosting property. Click edit.

7-f

Enable the Static website hosting

Choose to enable Static website hosting. Add index.html as your Index and Error document. Click on the Save Changes button below.

8

Scroll to the top of the page and choose the Permissions tab. We need to make changes to the S3 bucket policy. Click the Edit button as shown below.

9-f

Copy and enter the following bucket policy and replace the REPLACE_ME value with the bucket ARN of your bucket.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "REPLACE_ME/*"
        }
    ]
}
10-f

Click on save changes. We have now successfully configured a new S3 bucket for website hosting. Let us now deploy the React application to S3.

Deploy the React App to S3

Move to the project directory using your command line and run the following command.

npm run build

Note that this command created a build directory in your project.

11

Now go to your bucket in the S3 console and Click on the Upload button.

12-f

Use the Add files and Add folder button to upload all the files and the static folder in the build folder as shown below. Click the Upload button at the bottom of the page.

13-f

After a successful upload, close the upload page. Back in your S3 bucket Go to the properties tab find the URL of your S3 website in the static website hosting option and click on it.

15-f

You should see your create-react-app website on the screen.

14-f

You have now successfully created and deployed a React app to AWS S3.

I hope you found this blog post helpful on how to deploy a React Application to AWS S3. If you have any questions, please let me know in the comment session.

Rate this post

Thank you for reading this post. Kindly share it with others.

  • Share on X (Opens in new window) X
  • Share on Reddit (Opens in new window) Reddit
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Facebook (Opens in new window) Facebook
  • Share on Pinterest (Opens in new window) Pinterest
  • Share on Tumblr (Opens in new window) Tumblr
  • Share on Telegram (Opens in new window) Telegram
  • Share on WhatsApp (Opens in new window) WhatsApp
  • Share on Pocket (Opens in new window) Pocket
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on Bluesky (Opens in new window) Bluesky
  • Share on Threads (Opens in new window) Threads
  • Share on Nextdoor (Opens in new window) Nextdoor
AWS/Azure/OpenShift Tags:AWS, AWS s3

Post navigation

Previous Post: Set up and configure Route 53 for your Domain in AWS
Next Post: How to Install Jenkins Automation Server on Ubuntu 20.04 LTS

Related Posts

  • Screenshot 2022 03 20 at 20.37.16
    Setup HTTPS users using Git credentials and Pushing Code to AWS CodeCommit AWS/Azure/OpenShift
  • redirects3endpoint
    How to redirect requests for your bucket’s website endpoint to another bucket or domain AWS/Azure/OpenShift
  • Route53AWS
    Set up and configure Route 53 for your Domain in AWS AWS/Azure/OpenShift
  • powershell01 3
    How to install and Update Azure PowerShell on your Windows PC AWS/Azure/OpenShift
  • EC2 Public IP
    How to Allocate, Associate, Disassociate and Release Elastic IP Address from an EC2 Instance AWS/Azure/OpenShift
  • s3versioning
    Hosting Static Website and Versioning on AWS S3 AWS/Azure/OpenShift

More Related Articles

Screenshot 2022 03 20 at 20.37.16 Setup HTTPS users using Git credentials and Pushing Code to AWS CodeCommit AWS/Azure/OpenShift
redirects3endpoint How to redirect requests for your bucket’s website endpoint to another bucket or domain AWS/Azure/OpenShift
Route53AWS Set up and configure Route 53 for your Domain in AWS AWS/Azure/OpenShift
powershell01 3 How to install and Update Azure PowerShell on your Windows PC AWS/Azure/OpenShift
EC2 Public IP How to Allocate, Associate, Disassociate and Release Elastic IP Address from an EC2 Instance AWS/Azure/OpenShift
s3versioning Hosting Static Website and Versioning on AWS S3 AWS/Azure/OpenShift

Comments (2) on “How to deploy a React Application to AWS S3”

  1. Avatar photo Sidd Saran says:
    16/07/2022 at 7:48 PM

    Thanks. This was helpful!

    Log in to Reply
    1. chris Christian says:
      18/07/2022 at 11:16 PM

      You are welcome

      Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a

  • Wiki in Linux
    How to Use Wiki from Linux Terminal Linux
  • fast user switching in windows 10 1
    Fast user switching: How to create a desktop shortcut in Windows 10 to switch User Accounts Windows
  • screenshot 2020 04 17 at 17.09.01
    How to configure a remote Windows Server to Support Ansible Windows Server
  • aks 1
    Azure Storage: How to create Blob Storage and upload files AWS/Azure/OpenShift
  • Burn ISO on MAC   Proxmox installation
    Create a bootable USB on Mac: Proxmox VE Setup Virtualization
  • update powershell in Windows
    Upgrade PowerShell Core Windows or Mac and Linux System Windows
  • Install SQL Server Management Studio 21 on Windows Server
    Install SQL Server Management Studio 21 on Windows Server Oracle/MSSQL/MySQL
  • Block ZIPRAR Attachments in Outlook 2016 – 2007
    How to Block ZIP/RAR Attachments in Outlook Windows

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,836 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.