0Pricing
Vue Academy · Lesson

Deploying to Hosting Platforms

Deploy Vue apps to static hosts and platforms.

Deploying to Hosting Platforms is a free Vue Academy lesson on CoddyKit — lesson 2 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Vue Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Shipping Your App

A Vue SPA builds to static files, so you can host it on any static host. Platforms like Netlify, Vercel, and GitHub Pages make deploying these files fast and often free.

What You Deploy

You deploy the contents of the dist folder produced by npm run build. The host serves these files over a CDN to users worldwide.

npm run build
# upload the dist/ folder to your host

Deploying to Netlify

Netlify can build from your Git repo. You tell it the build command and the folder to publish.

# Netlify settings
# Build command: npm run build
# Publish directory: dist

Deploying to Vercel

Vercel auto-detects Vite projects. Connect your repository and it runs the build and serves the output, redeploying on every push.

# Vercel auto-detects:
# Build command: npm run build
# Output directory: dist

Deploying to GitHub Pages

GitHub Pages serves static files from a repository. You build locally or in CI, then push the dist output to the Pages branch or use an action.

The History Mode Problem

Vue Router in history mode creates clean URLs like /about. But a static host has no real /about file, so a direct visit or refresh returns a 404.

The SPA Redirect Fix

The solution is to tell the server to serve index.html for all routes, letting the Vue Router handle routing on the client.

Netlify Redirect Rule

On Netlify, add a _redirects file (or netlify.toml rule) that rewrites all paths to index.html.

# public/_redirects
/*    /index.html   200

Vercel Rewrite Rule

On Vercel, a vercel.json rewrite achieves the same fallback to index.html.

{
  "rewrites": [
    { "source": "/(.*)", "destination": "/index.html" }
  ]
}

Base Path Configuration

If your app is served from a subpath (common on GitHub Pages like /my-repo/), set the base option in your Vite config so asset URLs resolve correctly.

// vite.config.js
export default {
  base: "/my-repo/"
}

CI Deployment

Automate deploys with continuous integration. A workflow installs dependencies, runs tests, builds, and publishes on every push to your main branch, so shipping is hands-off.

# CI steps
# 1. npm install
# 2. npm run test
# 3. npm run build
# 4. deploy dist/

Quick Check

Test your knowledge of deployment.

Recap

Deploy the dist folder to a static host like Netlify, Vercel, or GitHub Pages. Add an SPA fallback (redirect/rewrite to index.html) so history-mode routes work on refresh, set the Vite base for subpath hosting, and automate it all with CI. Next you will monitor and maintain the app in production.

Frequently asked questions

Is the “Deploying to Hosting Platforms” lesson free?

Yes — the full text of “Deploying to Hosting Platforms” is free to read here on the web, and the Vue Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Vue Academy course, upgrade to CoddyKit PRO.

What will I learn in “Deploying to Hosting Platforms”?

Deploy Vue apps to static hosts and platforms. You practise Vue Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Vue Academy?

No prior experience is required. Vue Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 3, so you can start here or from the beginning and move at your own pace.

How long does the “Deploying to Hosting Platforms” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Vue Academy lesson?

Yes. Every Vue Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Optimizing the Build Process
  2. Deploying to Hosting Platforms
  3. Monitoring and Maintenance
← Back to Vue Academy