DEV Community

Naveen Kumar
Naveen Kumar

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
    Image description

  3. Now run the following commands:

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

  5. Create a bucket.
    Image description

  6. Upload the files and folders in the dist.
    Image description

  7. Enable static web hosting.
    Image description

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

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

  10. Create a new distribution.
    Image description

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

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

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

Top comments (0)