Deploy Vite on AWS

Deploy your Vite single-page applications (SPAs) to AWS using Thunder patterns. This guide covers static site deployment using S3 and CloudFront.

Vite applications are deployed using the Static construct, which provides optimized static hosting with CDN distribution.

Static Deployment


Deploy Vite SPAs to S3 and CloudFront using the Static construct.

Create Project

Terminal window
npm create vite@latest my-vite-app -- --template vanilla-ts
cd my-vite-app
npm install

Install Dependencies and Setup Stack

Terminal window
npm i tsx @thunder-so/thunder --save-dev
stack/index.ts
import { Cdk, Static, type StaticProps } from "@thunder-so/thunder";
const myApp: StaticProps = {
env: {
account: 'your-account-id',
region: 'us-east-1'
},
application: 'your-application-id',
service: 'your-service-id',
environment: 'production',
rootDir: '', // e.g. 'frontend' for monorepos
outputDir: 'dist',
};
new Static(
new Cdk.App(),
`${myApp.application}-${myApp.service}-${myApp.environment}-stack`,
myApp
);

Deploy

Build and deploy your Vite SPA:

Terminal window
npm run build
npx cdk deploy --all --app="npx tsx stack/index.ts"

After deployment, you’ll receive a CloudFront URL to access your static site.