S3 Amazon Static Website with React? S3 Amazon Static Website with React? reactjs reactjs

S3 Amazon Static Website with React?


It's possible to host a static react site entirely on s3. In this case, you would use node/npm only as build tools and to run your development server (localhost:3000).

npm would download your dependencies and you'd use node or gulp or webpack to build the assets into static files.

Then you would upload the files to s3 where it would serve the static files.

If you have some backend node code, then you would need to use ec2 or some other type of host. But if it's entirely static javascript, then there's no need for a node server.

Here are some links that might help explain in more detail:


Try Gatsby! Here: https://www.gatsbyjs.org/

From the Github page: "Blazing fast static site generator for React"

Once you've generated your static pages, you can deploy on S3, Github pages...the choice is yours!


You can skip EC2 for your case. Here is why:

1) S3 Bucket + CloudFront (CDN) is really fast for static files serving. The React minified app is a group of static files which works best here. For the build of those minified files, I recommend using a CI/CD process or build them locally and just upload them to S3.

2) EC2 requires more work to setup, it consumes resources, it is not necessary for static files or React (unless you are using ReactDOMServer for dynamic content serving), and Node.js is not recommended for static files (Node.js get's blocked since it is single threaded so it is a best practice to keep static files away from it).

Here is a good article on the topic using Angular as an example: https://www.quora.com/Should-I-use-AWS-EC2-to-host-an-Angular-web-app-or-AWS-S3