Creating a Project with Vite
Vue projects are scaffolded with create-vue, an official scaffolding tool built on top of Vite. It gives you a fully configured project in one command.
Running the scaffolder
Section titled “Running the scaffolder”Open a terminal and run:
npm create vue@latestYou’ll be prompted to name your project and choose features:
✔ Project name: … family-tree✔ Add TypeScript? … Yes✔ Add JSX Support? … No✔ Add Vue Router for Single Page Application development? … Yes✔ Add Pinia for state management? … Yes✔ Add Vitest for Unit Testing? … No✔ Add an End-to-End Testing Solution? … No✔ Add ESLint for code quality? … Yes✔ Add Prettier for code formatting? … NoFor FamilyTree you will select TypeScript, Vue Router, Pinia, and ESLint. Skip the rest.
Installing dependencies and starting the server
Section titled “Installing dependencies and starting the server”After scaffolding, install dependencies and start the dev server:
cd family-treenpm installnpm run devVite starts a dev server — typically at http://localhost:5173 — with instant hot module replacement. Changes to .vue files are reflected in the browser without a full page reload.
Why Vite?
Section titled “Why Vite?”Vite is the build tool that powers create-vue projects. Unlike older tools (Webpack, Parcel), Vite:
- Uses native ES modules in the browser during development — no bundling step, so startup is near-instant
- Performs fast HMR (Hot Module Replacement) by only updating the changed module
- Produces an optimized production bundle with
npm run build
You won’t configure Vite directly in this course. The defaults work well. The key commands are:
| Command | What it does |
|---|---|
npm run dev | Start the dev server with HMR |
npm run build | Build the production bundle into dist/ |
npm run preview | Preview the production build locally |
Exercise
Section titled “Exercise”- Run
npm create vue@latestand scaffold a project calledmy-first-vue-appwith TypeScript and Vue Router enabled (skip Pinia and others for now). - Run
npm installandnpm run dev. - Open
http://localhost:5173and confirm you see the default Vue welcome page. - Open
src/App.vueand change the text inside the<h1>tag to something else. Confirm the change appears in the browser instantly without refreshing.
npm create vue@latestscaffolds a Vue 3 project with create-vue — select TypeScript, Vue Router, and Pinia for FamilyTree.npm run devstarts a Vite dev server with instant HMR.npm run buildproduces the optimized production bundle.- Vite uses native ES modules in development — no bundling step means near-instant startup.