How to deploy create-react-app in AWS EC2 How to deploy create-react-app in AWS EC2 reactjs reactjs

How to deploy create-react-app in AWS EC2


You can use Amazon S3.

Do npm run build in your local instance.

Upload the files to S3 bucket instance.

Static website hosting can be chosen.

https://s3.console.aws.amazon.com/s3/buckets


I'm a little bit new to React, but I wanna add my experience here.I deployed my CRA app on AWS EC2 using Apache.

  • You follow this link to install Apache after launching the EC2 instance.
  • Build your react app and upload 'build' folder.

Now done. Finally, make sure to use HashRouter rather than BrowserRouter.Because EC2 didn't allow the .htaccess file to redirect all requests to index.html, but replacing BrowserRouter with HashRouter helped me solve that issue.Hope this helps others save the time. Thanks.