Vue Vite Starter

A Vue 3 single-page app starter in JavaScript, built with Vite 8 and Vue Router 4 using the Composition API and <script setup>. It is for developers who want a clean Vue project with a shared layout, Home, About and 404 views, scoped styles, ESLint and Vitest with Vue Test Utils.

by Light CloudSingle-page apps

Build a single-page app with Vue 3, Vite and Vue Router

Vue 3 Vite Starter: home page with a click counter and Home and About navigation
Vue 3 Vite Starter: home page with a click counter and Home and About navigation, on a phone

Features

  • Vue Router 4 with HTML5 history: / with a click counter, /about, and a catch-all 404 view
  • About and 404 views are lazy-loaded, so each is its own chunk fetched on first visit
  • A DefaultLayout (header, navigation, footer) around every view
  • Scoped styles per component, with design tokens and base styles in src/assets/main.css
  • An @ alias for src/ in vite.config.js, used for lazy route imports
  • ESLint flat config with eslint-plugin-vue, and a Vitest test for CounterButton with Vue Test Utils
  • VITE_APP_TITLE sets the name in the header at build time, documented in .env.example

Tech stack

What you need

  • Free plan: it builds to a static site, which the Free plan hosts with no limit on sites
  • To run it locally: Node.js 22.12 or later and npm
  • No API keys: it starts with nothing to configure

About

The project sticks to Vue, Vue Router and Vite with no extra state library, so it stays small and easy to read. Routes are declared in src/router/index.js and views live in src/views/, with the layout kept separate in src/layouts/. Most people start by editing HomeView.vue, then add views and, when they need shared state, Pinia. Deploying runs npm run build and serves dist/ from a CDN, with unknown paths sent to index.html for Vue Router.

FAQ

How do I add a new page to a Vue 3 Vite app?

Create a view in src/views/, add a route with component: () => import('@/views/ContactView.vue') to src/router/index.js, and add a RouterLink in src/layouts/DefaultLayout.vue.

Why does Vue Router history mode give a 404 on refresh?

HTML5 history mode needs the host to serve index.html for paths that are not files. Add a rewrite or SPA fallback on your host; Light Cloud does this for you.

Does this Vue starter include Pinia or TypeScript?

No, it keeps to Vue and Vue Router. Install pinia and call app.use(createPinia()) in src/main.js when you need shared state, and add typescript and vue-tsc for type checking.

How do I use environment variables in Vue with Vite?

Add a line such as VITE_API_URL=https://api.example.com to .env.local and read it with import.meta.env.VITE_API_URL. Values are written into the bundle at build time, so never put secrets in them.

Can I host this Vue template without Light Cloud?

Yes. Run npm run build and serve dist/ from any static host, with a fallback to index.html for client-side routes.

Price
Free
Framework
Vue · JavaScript
Plan
Free
Updated