Skip to the workspace
Pebellslearn by building
Components  ›  Lesson

create-vue — Your First Project

create-vue 12 mincreate-vue scaffolds a ready-to-run Vue project on Vite, and main.js mounts the root App component onto a page element.

vue / create-vue — Your First Project

Explore each scene at your own pace.

01 · The rule

The rule

create-vue — Your First Project

You want to build Shelf, a small app that tracks the books you are reading. Before writing a single component you need a folder with Vue installed, a dev server that reloads as you type, and a build step for later. Setting that up by hand takes an afternoon. One command does it in a minute.

The rule

One command scaffolds; main.js mounts App onto #app.

create-vue is Vue's official project starter. You run it through npm:

npm create vue@latest

It asks for a project name (we type shelf) and then a short list of yes or no questions: TypeScript? Vue Router? Pinia for shared state? A testing tool? Answer "No" to all of them for now; each one only adds files you can add later. Then:

cd shelf
npm install
npm run dev

npm install downloads Vue and Vite, the build tool create-vue sets up for you. npm run dev starts Vite's development server and prints a local address, usually http://localhost:5173. Open it and the starter page appears. Save a file and the page updates at once.

Three files explain how the page gets there:

// src/main.js
import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')
  • index.html is the one real HTML page. It holds an empty <div id="app"></div> and loads src/main.js.
  • src/main.js creates the Vue application from the root component and mounts it on that div.
  • src/App.vue is the root component: everything else in Shelf will live inside it.
Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.