Deploy a Vite React SPA on AWS
You can deploy a Vite site with React.js on AWS with Thunder. The server pre-rendered pages produced by the build step will be stored in an S3 bucket and served using CloudFront CDN.
View code in StackBlitz
Build Settings
Use the following commands in the build step settings:
That’s it! Your app will be live on your CloudFront URL as soon as the build finishes.
Environment Variables
Environment variables in Vite are available at build time and can be used both in your config files and templates. For more information, refer to the official Vite documentation on environment variables.
You can define them in an .env file at the root of your project:
Use it in your templates: