web development / vue
Learn Vue.js for Free: Reactivity, Single-File Components and the Official Tutorial
Vue is quick to start and easy to misuse if you skip how reactivity works. This guide covers what create-vue sets up, the three reactivity tools that matter first, and a tested single-file component that you can paste into a new project.
Vue is a JavaScript framework for building user interfaces, and its learning curve is gentle at the start. You can drop a script tag on a page and have a working counter in minutes. That ease is also the trap: people who learn Vue by copying snippets never build a mental model of what makes the page update, and the model is the whole skill.
This page starts with the official project setup, then spends most of its time on reactivity. The code here uses the Composition API with script setup, which is what the official quick start generates, so what you learn matches what you will find in new projects.
01 · SETUP
What create-vue gives you, and what to say no to
The Vue quick start uses create-vue, the official scaffolding tool, which sets up a Vite-based build with Single-File Components. The page lists Node.js version ^22.18.0 || >=24.12.0 as the prerequisite, so check node --version first. Then run the command below and answer the prompts.
npm create vue@latest cd <your-project-name> npm install npm run dev
The tool asks about optional features: TypeScript, Vue Router, Pinia, Vitest, an end-to-end testing solution, ESLint and Prettier. The quick start says that if you are unsure, choose No.
| Prompt | Say | Reason |
|---|---|---|
| TypeScript | No at first | Learn Vue's ideas before adding a type system |
| Vue Router | No for the first project | A single-screen app does not need routing yet |
| Pinia | No | Shared state is only worth adding when two distant components need the same data |
| Vitest | Yes, once you are ready to test | Component tests are how you learn to trust reactivity |
| ESLint and Prettier | Yes | They catch mistakes and end style arguments |
create-vue project look different. Pick one style per project.02 · REACTIVITY
ref, computed and when each one fits
Vue re-renders what depends on reactive data when that data changes. The Reactivity Fundamentals page of the official guide is the best explanation, and these are the three tools you meet first.
| Tool | Use it for | Example |
|---|---|---|
| ref | A value that changes and the page should react | const query = ref('') |
| computed | A value derived from other reactive values | Filtered list from a search box |
| watch | A side effect when data changes, such as saving or fetching | Fetch results when an id changes |
The most common mistake is to use watch or a second ref for something you could compute. The component below keeps a single source of truth, the query, and derives the visible list from it.
03 · A WORKED EXAMPLE
A searchable list as a single-file component
<script setup>
import { ref, computed } from 'vue'
const trails = ['Ridge loop', 'River path', 'Summit spur']
const query = ref('')
// recalculated only when query changes; never stored by hand
const visible = computed(() =>
trails.filter((t) => t.toLowerCase().includes(query.value.toLowerCase()))
)
</script>
<template>
<label>Search <input v-model="query" /></label>
<ul>
<li v-for="t in visible" :key="t">{{ t }}</li>
</ul>
<p>{{ visible.length }} of {{ trails.length }} shown</p>
</template>This was built with Vite and the Vue plugin on Vue 3.5.44 and loaded in Chromium. It starts at "3 of 3 shown". Typing ri leaves Ridge loop and River path with "2 of 3 shown", and typing zzz leaves no items and "0 of 3 shown", with no console errors.
Notice that inside script you write query.value, but in the template you write query. Vue unwraps refs in templates. Forgetting .value in the script is the single most common beginner error, and the symptom is a filter that silently matches nothing.
Each of the three blocks has a job: script setup holds state and logic, template holds markup, and an optional style block holds CSS. The :key on v-for gives each item a stable identity so Vue updates the right element when the list changes.
04 · WHEN YOU NEED MORE
Router and Pinia, added one at a time
Add Vue Router when your app has more than one screen with its own URL, and Pinia when several components need the same shared state. Both have short official getting-started pages. Add them after your first small app works, not with the first scaffolding command, so you can see what each one fixes.
If you are still deciding whether Vue is the right framework, MDN has a framework-neutral introduction to client-side frameworks that explains the problems any of them solves.
05 · FREE RESOURCES
The official material, in order
- Vue tutorial ↗The official step-by-step tutorial.vuejs.org
- Vue quick start ↗The create-vue command, the Node version requirement and the first run.vuejs.org
- Reactivity fundamentals ↗ref, reactive and how templates unwrap them.vuejs.org
- Computed properties ↗Why derived values belong in computed.vuejs.org
- Template syntax ↗The directives and interpolation used in the example.vuejs.org
- List rendering ↗v-for and the key attribute.vuejs.org
- Single-File Components ↗The structure of a .vue file.vuejs.org
- Composition API FAQ ↗The official comparison of Composition API and Options API.vuejs.org
- Vue Router: getting started ↗Add routing when you have multiple screens.router.vuejs.org
- Pinia: getting started ↗Shared state management for larger apps.pinia.vuejs.org
- MDN: introduction to client-side frameworks ↗A framework-neutral explanation of why frameworks exist.developer.mozilla.org
06 · FAQ
Frequently asked questions
Do I need to know JavaScript before learning Vue?
Yes. Vue is built on JavaScript, so you should be comfortable with functions, arrays, objects, and modules first. Weak JavaScript is the main reason Vue code feels like magic instead of logic.
What do I need installed to start a Vue project?
Node.js. The Vue quick start lists version ^22.18.0 or >=24.12.0 as the requirement at the time of checking. Then run npm create vue@latest and follow the prompts.
Should I learn the Composition API or the Options API?
Start with the Composition API using script setup, which is what the official create-vue project generates. The Composition API FAQ in the Vue guide compares the two if you need to read older code.
Why is my ref not updating in the script?
Inside script you read and write a ref through its value property, for example query.value. Templates unwrap refs automatically, so there you use just the name. Forgetting value is the most common beginner error.
Is Vue free to use?
The official tutorial, guide and the quick start at vuejs.org are free to read, and create-vue scaffolds a project at no cost. Vue Router and Pinia have their own free documentation sites.