DEV Community

Naveen Kumar J
Naveen Kumar J

Posted on

Hosting a React App in AWS using CloudFront

  1. Install node.js in your computer.

  2. Create a React app in the terminal using create vite@latest

  3. Now run the following commands:

    • cd "project name"
    • npm install
    • npm run dev
  4. now run the command "npm run build" to create 'dist' in the project folder to upload to the S3 bucket.

  5. Create a bucket.

  6. Upload the files and folders in the dist.

  7. Enable static web hosting.

  8. Copy the Bucket ARN and generate bucket policy by clicking "policy generator" in Edit Bucket Policy.

  9. Copy and paste the JSON document in the policy.



  10. Create a new distribution.

  11. Copy the Distribution domain name and open it in a new tab.

  12. Your react application will be hosted using AWS CloudFront.

  13. Empty the Bucket and delete the bucket and distribution.

Top comments (0)