How to deploy Vue app to AWS Amplify

AWS Amplify provides fully managed hosting for Vue applications with automatic builds, custom domains, and serverless backend integration. As the creator of CoreUI with 12 years of Vue.js development experience, I’ve deployed hundreds of Vue applications to AWS Amplify, serving millions of users with global CDN distribution and instant SSL certificates.

The fastest approach uses Amplify Console with GitHub integration for automatic deployments.

Install Amplify CLI

npm install -g @aws-amplify/cli

# Configure Amplify
amplify configure

Initialize Amplify Project

# Navigate to your Vue project
cd my-vue-app

# Initialize Amplify
amplify init

# Follow prompts:
# ? Enter a name for the project: myvueapp
# ? Enter a name for the environment: dev
# ? Choose your default editor: Visual Studio Code
# ? Choose the type of app: javascript
# ? What javascript framework: vue
# ? Source Directory Path: src
# ? Distribution Directory Path: dist
# ? Build Command: npm run build
# ? Start Command: npm run serve

Add Hosting

# Add hosting with Amplify Console
amplify add hosting

# Select:
# ? Select the plugin module to execute: Hosting with Amplify Console
# ? Choose a type: Manual deployment

# Or for CI/CD
# ? Choose a type: Continuous deployment (Git-based deployments)

Deploy

# Build and deploy
npm run build
amplify publish

# Your app will be deployed to:
# https://dev.d1234abcd5678.amplifyapp.com

Configure Build Settings

Create amplify.yml in project root:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Environment Variables

Add in Amplify Console:

  1. Go to App Settings → Environment variables
  2. Add variables:
    • VITE_API_URL: https://api.example.com
    • VITE_API_KEY: your-api-key

Access in Vue:

// Use in components
const apiUrl = import.meta.env.VITE_API_URL
const apiKey = import.meta.env.VITE_API_KEY

Custom Domain

# Add custom domain via CLI
amplify add domain

# Or in Amplify Console:
# 1. Go to Domain management
# 2. Add domain
# 3. Configure DNS records

Configure DNS with your provider:

Type   Name                Value
CNAME  www                 d1234abcd5678.amplifyapp.com
CNAME  @                   d1234abcd5678.amplifyapp.com

Branch-Based Deployments

In Amplify Console:

  1. Connect repository (GitHub, GitLab, Bitbucket)
  2. Select branch patterns:
    • main → production
    • develop → staging
    • feature/* → preview

Each branch gets its own URL:

  • https://main.d1234abcd5678.amplifyapp.com
  • https://develop.d1234abcd5678.amplifyapp.com
  • https://feature-new-ui.d1234abcd5678.amplifyapp.com

Add Backend API

# Add REST API
amplify add api

# Select:
# ? Please select from one of the below: REST
# ? Provide a friendly name: myapi
# ? Provide a path: /items
# ? Choose a Lambda source: Create a new Lambda function

# Deploy API
amplify push

Use in Vue:

<script setup>
import { Amplify, API } from 'aws-amplify'
import awsconfig from './aws-exports'

Amplify.configure(awsconfig)

const fetchItems = async () => {
  try {
    const response = await API.get('myapi', '/items')
    console.log(response)
  } catch (error) {
    console.error(error)
  }
}
</script>

Add Authentication

# Add Cognito authentication
amplify add auth

# Select:
# ? Do you want to use default configuration? Default
# ? How do you want users to sign in? Email
# ? Do you want to configure advanced settings? No

# Deploy auth
amplify push

Use in Vue:

<script setup>
import { Amplify, Auth } from 'aws-amplify'
import awsconfig from './aws-exports'

Amplify.configure(awsconfig)

const signUp = async (email, password) => {
  try {
    const user = await Auth.signUp({
      username: email,
      password,
      attributes: { email }
    })
    console.log('User signed up:', user)
  } catch (error) {
    console.error('Sign up error:', error)
  }
}

const signIn = async (email, password) => {
  try {
    const user = await Auth.signIn(email, password)
    console.log('User signed in:', user)
  } catch (error) {
    console.error('Sign in error:', error)
  }
}
</script>

Configure Redirects for SPA

Update amplify.yml:

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: dist
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*
customHeaders:
  - pattern: '**/*'
    headers:
      - key: 'Cache-Control'
        value: 'public, max-age=31536000, immutable'
      - key: 'Strict-Transport-Security'
        value: 'max-age=31536000; includeSubDomains'

Create public/_redirects:

/*    /index.html   200

Rollback Deployment

In Amplify Console:

  1. Go to App → Hosting
  2. Click on deployment to rollback
  3. Click “Redeploy this version”

Or via CLI:

amplify env checkout production
amplify pull
amplify publish

Monitor Performance

In Amplify Console:

  1. Go to Monitoring
  2. View metrics:
    • Request count
    • Data transfer
    • 4xx/5xx errors
    • Response times

Add CloudWatch alarms:

# Create alarm for 5xx errors
aws cloudwatch put-metric-alarm \
  --alarm-name high-error-rate \
  --alarm-description "Alert when 5xx errors exceed threshold" \
  --metric-name 5xxErrors \
  --namespace AWS/Amplify

Best Practice Note

This is how we deploy CoreUI Vue templates to AWS Amplify for enterprise-grade hosting with AWS integration. Amplify provides automatic builds, branch previews, and seamless integration with AWS services like Cognito, API Gateway, and Lambda. Always configure SPA redirects, use environment variables for configuration, enable branch-based deployments for staging environments, and leverage built-in CI/CD for automatic deployments on git push.

For production applications, consider using CoreUI’s Vue Admin Template which includes AWS Amplify deployment configurations.

For other deployment options, check out how to deploy Vue app to Vercel and how to deploy Vue app to Firebase.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author