Hosting a React SPA on AWS S3 & CloudFront
Build a React app, upload to S3, configure CloudFront distribution and cache invalidation.
S3 Static Hosting Overview
AWS S3 can serve static files (HTML, JS, CSS, images) as a website. Combined with CloudFront (CDN), you get global distribution, HTTPS, and low latency for React SPAs.
Building the SPA
Build your React app to a static output directory.
# Vite:
npm run build # outputs to dist/
# Create React App:
npm run build # outputs to build/
# Next.js static export:
next build && next export # outputs to out/All lessons in this course
- Deploying to Vercel: Zero-Config & Preview URLs
- Hosting a React SPA on AWS S3 & CloudFront
- Dockerizing a React/Next.js App
- GitHub Actions CI/CD for React