Skip to main content

Vue Guide

Build a counter in Vue and the number on screen changes from count.value++ alone. Behind that convenience, machinery is running that tracks every read and write of the value. You can keep writing without knowing how it works and still ship something, but you will stall on "why does reassigning it stop being reactive?" and "why does destructuring break it?"

This guide aims to explain the Vue 3.5 API from its design intent. It is not a catalogue of syntax; it covers why each way of writing was chosen, and what breaks when you go against it.

About this guide​

The subject is the Composition API and script setup. The Options API comes up when you need to read existing code, but it is not treated as something to write from scratch. Every code example is in TypeScript, and how far the types reach is part of the discussion.

The guide follows these principles throughout.

  • Write with script setup and TypeScript. The Options API is touched on only for reading existing code, never as something new to write
  • Make ref() the first choice for declaring state. This is the policy the official documentation states as its recommendation, and chapter 2 cites the source
  • Extract reusable units into composables
  • Use Pinia for state management
  • Cover Nuxt 4 where server-side rendering is needed
  • Leave out anything specific to Vue 2. Support ended at the end of 2023

Who this is for​

  • People who have manipulated the DOM in JavaScript and are looking for a way into a framework
  • People writing Vue who have tripped over how reactivity behaves
  • People with React experience who want to know how Vue's design thinking differs

Each chapter builds on the one before it, but the chapters from Vue Router onward can be read on their own.

Prerequisites​

LevelKnowledgeNotes
RequiredExperience building screens with HTML and CSSYou do not need the syntax memorised
RequiredBasic JavaScript syntaxDestructuring, arrow functions, and Promise notation are used without explanation. Where explaining Vue's behaviour demands it, though, the guide does go into how values are passed around
RecommendedBasic TypeScript type annotationsThe examples are in TypeScript, but they do not use complicated types
Not neededVue 2 experienceVue 2 reached end of support at the end of 2023 and is not covered here

Tech stack​

TargetVersionRole
Vue3.5The framework itself. 3.6 is a candidate release, so it is not the baseline
TypeScript5 or laterType annotations and checking via vue-tsc
Vite8Dev server and build
Vue Router5Navigation
Pinia4State management
Nuxt4Server-side rendering and file-based routing

Chapter outline​

The 20 chapters are split into six parts.

Part 1: Vue fundamentals​

ChapterWhat it covers
01 Setup and SFCsCreating a project with create-vue, and the three-block structure of a single-file component
02 ReactivityChoosing between ref and reactive. Why reassignment and destructuring break
03 Template syntax and directivesAttribute binding, conditionals, list rendering. Why key is needed
04 Events and form inputEvent modifiers and v-model. What changes when you add or drop the parentheses
05 Computed properties and watchersCaching in computed and side effects in watch. How to decide between them

Part 2: The Composition API​

ChapterWhat it covers
06 script setup and the component contractDeclaring the boundary between parent and child as types with defineProps and defineEmits
07 LifecycleThe order hooks run in, and which work belongs where
08 ComposablesExtracting logic into functions. The shape of arguments and return values, and where cleanup is handed off
09 Composables and server-side renderingWays of writing that break under SSR. The pitfalls of sharing state

Part 3: Building components​

ChapterWhat it covers
10 v-model between componentsWiring two-way binding with defineModel
11 SlotsLetting the parent render part of the component. Passing data with scoped slots
12 provide / inject and custom directivesPassing values past the hierarchy, and the means to touch the DOM directly
13 Teleport and SuspenseThe mechanism for moving where things render, and the one for handling async waiting declaratively

Part 4: Navigation and motion​

ChapterWhat it covers
14 TransitionsEnter and leave animations. The order classes are applied in, and the JavaScript hooks
15 Vue Router basicsRoute definitions, navigating from code, dynamic routes, nested routes
16 Navigation guards and optimisationIntercepting navigation, scroll control, lazy loading

Part 5: State and data​

ChapterWhat it covers
17 PiniaDefining and splitting stores. Why storeToRefs becomes necessary
18 HTTP requests and data fetchingWhere fetch logic lives, and how to handle environment variables

Part 6: Nuxt and practice​

ChapterWhat it covers
19 NuxtFile-based routing, useFetch, server APIs
20 Practice: authentication and deploymentBuilding the login flow and deciding where the token lives. Placing the build output

How each chapter is structured​

Every chapter follows the same shape.

SectionWhat goes in it
What you'll learnWhat you will be able to do once you finish the chapter
BodyHow the machinery works and how to make the call. Uses diagrams, tables, and code examples
SummaryThe key points of the chapter
Related referencesExisting guides to go deeper with, and links to the official documentation
What to read nextThe next chapter, plus routes into related chapters in other parts

This site already has guides organised by technology. This one narrows in on learning Vue as a framework, sending you to the JavaScript guide and the TypeScript guide for language features and to the Tailwind CSS guide for CSS. Which guide covers which stage across the whole site is laid out in the introduction.

The React guide sits alongside this one. Both are about composing components into a UI, but they hold state differently. React expresses a state update as a function call and puts the unit of re-rendering at the component. Vue embeds the tracking machinery in the value itself and updates only the places that depend on it. That difference surfaces in how key is handled and in whether memoisation is needed, so reading both widens the design options available to you.

How to read it​

  • New to Vue — read Part 1 in order, running the code as you go
  • Writing Vue but unsure about the machinery — chapters 02, 05, and 08 are worth reading on their own
  • Coming from React — get the difference in reactivity from chapter 02, then check how the parent-child contract is written in chapter 06
  • Looking up a specific feature — open the relevant chapter directly from the outline above

With that, let's start with Setup and SFCs.