Deploy a Vite Vue 3 SPA on AWS

You can deploy a Vite site with Vue 3 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:

Install command
npm install
Build command
npm run build
Output directory
public

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:

.env
VITE_BASE_URL=https://thunder.so

Use it in your templates:

<script setup lang="ts">
const url = import.meta.env.VITE_BASE_URL;
</script>
<template>
<div>
<a :href=url target="_blank">Thunder</a>
</template>