---
title: 'Deploy Vite on AWS'
description: 'Deploy Vite-based single-page applications on AWS using S3 and CloudFront.'
---
import { Tabs, TabItem, Aside } from '@astrojs/starlight/components';
import PatternList from '../../../components/docs/PatternList.astro';
import FrameworkHero from '../../../components/docs/FrameworkHero.astro';
Deploy your [Vite](https://vitejs.dev/) single-page applications to AWS using Thunder. Vite apps are fully client-rendered at runtime, making static hosting on [S3](https://aws.amazon.com/s3/) and [CloudFront](https://aws.amazon.com/cloudfront/) the natural fit.
## Available Patterns
## Prerequisites
## Getting Started
### Create Project
Scaffold a new Vite project using your preferred package manager. This sets up the project structure, installs dependencies, and prepares you for development.
```sh
bun create vite my-vite-app --template vanilla-ts
cd my-vite-app
bun install
```
```sh
npm create vite@latest my-vite-app -- --template vanilla-ts
cd my-vite-app
npm install
```
```sh
pnpm create vite my-vite-app --template vanilla-ts
cd my-vite-app
pnpm install
```
### Install Thunder
Add Thunder as a development dependency. It provides the CDK constructs you'll use to define your AWS infrastructure.
```sh
bun add @thunder-so/thunder --development
```
```sh
npm install @thunder-so/thunder --save-dev
```
```sh
pnpm add -D @thunder-so/thunder
```
---
## Vite Static Site Deployment
Deploy your Vite SPA to [S3](https://aws.amazon.com/s3/) with [CloudFront](https://aws.amazon.com/cloudfront/) as the CDN. Vite outputs all compiled assets to `dist/` by default — Thunder uploads these directly to S3 and provisions the CloudFront distribution in front of them.
### Stack
The `Static` construct provisions an S3 bucket, a CloudFront distribution, and optionally a Route53 DNS record.
```ts title="stack/prod.ts"
import { Cdk, Static, type StaticProps } from '@thunder-so/thunder';
const config: StaticProps = {
env: { account: 'YOUR_ACCOUNT_ID', region: 'us-east-1' },
application: 'myapp',
service: 'web',
environment: 'prod',
rootDir: '.', // e.g. 'frontend' for monorepos
outputDir: 'dist',
};
new Static(new Cdk.App(), `${config.application}-${config.service}-${config.environment}-stack`, config);
```
### Deploy
Build your Vite app first to compile and bundle all assets into `dist/`, then deploy with CDK. CDK uploads the files to S3 and provisions the CloudFront distribution.
```sh
bun run build
npx cdk deploy --app "bunx tsx stack/prod.ts" --profile default
```
```sh
npm run build
npx cdk deploy --app "npx tsx stack/prod.ts" --profile default
```
```sh
pnpm run build
pnpm exec cdk deploy --app "pnpm exec tsx stack/prod.ts" --profile default
```
After deployment, CDK outputs a **CloudFront URL** where your app is live.