Vue.js 3 (with Pinia, Vue Router & Nuxt basics)
What it is & where it is used
Vue.js is a progressive JavaScript framework for building user interfaces, created by Evan You (ex-Google, worked on AngularJS) in 2014. "Progressive" means you can use it as a drop-in script to enhance a page, or as a full SPA framework with router, state management and SSR.
Key characteristics:
- Single-File Components (SFCs) —
.vuefiles with<template>,<script>and<style>together. - Declarative templates with directives (
v-if,v-for,v-model,v-bind,v-on). - Fine-grained reactivity — Vue tracks which components depend on which state (via JavaScript Proxies in Vue 3) and re-renders only what's needed.
- Two API styles: Options API (
data,methods,computed) and Composition API (ref,reactive,computedinside<script setup>). - Official ecosystem: Vue Router, Pinia (state), Vite (build tool, also created by Evan You), Vue DevTools, Nuxt (full-stack framework, third-party but closely aligned).
Vue sits between AngularJS-style templates and React-style components: approachable for beginners, scalable for large apps (used by Alibaba, Xiaomi, GitLab, Nintendo and many Asian companies).
Versions & history
| Version | Date | Highlights |
|---|---|---|
| 0.x | Feb 2014 | First public release |
| 1.0 | Oct 2015 | "Evangelion" |
| 2.0 | Sep 2016 | Virtual DOM, server-side rendering, render functions |
| 2.5 / 2.6 | 2017 / 2019 | Better TypeScript; 2.6 v-slot syntax |
| 2.7 | Jul 2022 | "Naruto" — backports Composition API and <script setup> to Vue 2 |
| — | 31 Dec 2023 | Vue 2 end of life (commercial extended support available, e.g. HeroDevs) |
| 3.0 | Sep 2020 | "One Piece": Composition API, Proxy-based reactivity, Fragments, Teleport, Suspense, better TypeScript, smaller and faster |
| 3.2 | Aug 2021 | <script setup> stable, v-memo, defineCustomElement |
| 3.3 | May 2023 | Generic components, imported types in defineProps, defineOptions, defineSlots |
| 3.4 | Dec 2023 | Rewritten template parser (2× faster), defineModel stable, v-bind same-name shorthand |
| 3.5 | Sep 2024 | Reactivity memory/performance overhaul, reactive props destructure, useTemplateRef, useId, lazy hydration, onWatcherCleanup |
| 3.6 (in development) | 2025– | Vapor Mode (compile without virtual DOM, opt-in, alpha), alien-signals based reactivity |
Ecosystem: Vuex (official store for Vue 2) → Pinia became the official recommendation (2022). Vue CLI (webpack) → create-vue + Vite. Nuxt 3 (2022), Nuxt 4 (July 2025).
Lifecycle
Component lifecycle (Composition API hook → Options API name):
| Phase | Composition API | Options API | Use |
|---|---|---|---|
| Setup | setup() / <script setup> runs | beforeCreate, created | Initialise state; no DOM yet |
| Before mount | onBeforeMount | beforeMount | Template compiled, about to render |
| Mounted | onMounted | mounted | DOM available — fetch data, third-party libs, focus |
| Before update | onBeforeUpdate | beforeUpdate | State changed, before DOM patch |
| Updated | onUpdated | updated | DOM patched (avoid changing state here) |
| Before unmount | onBeforeUnmount | beforeUnmount (Vue 2: beforeDestroy) | Cleanup start |
| Unmounted | onUnmounted | unmounted (Vue 2: destroyed) | Remove listeners, timers |
| Errors | onErrorCaptured | errorCaptured | Error from a descendant |
| KeepAlive | onActivated / onDeactivated | activated / deactivated | Cached components shown/hidden |
| SSR | onServerPrefetch | serverPrefetch | Fetch data during SSR |
Reactivity update cycle: state change → the reactive Proxy's set trap triggers the effects (components, computeds, watchers) that read that property → component re-render is queued and batched in the next microtask (nextTick) → virtual DOM diff (optimised by compiler hints: static hoisting, patch flags, block tree) → DOM patched → onUpdated.
App bootstrap: createApp(App) → app.use(router), app.use(createPinia()), global components/directives → app.mount("#app").
Tools used to develop
| Tool | Use |
|---|---|
npm create vue@latest (create-vue) | Scaffold a Vite-based project (TS, Router, Pinia, Vitest, ESLint options) |
| Vite | Dev server and build |
| Vue DevTools (browser extension + Vite plugin) | Inspect components, Pinia, router, timeline |
| VS Code + Vue - Official extension (Volar) | SFC IntelliSense and type checking (vue-tsc) |
| Vue Router, Pinia | Routing and state |
| VueUse | Collection of composables |
| Vuetify, PrimeVue, Element Plus, Naive UI, Quasar | UI libraries |
| VeeValidate, FormKit, Zod/Yup | Forms and validation |
| Vitest + Vue Test Utils, Playwright/Cypress | Testing |
| Nuxt | SSR/SSG/full-stack framework |
| Vite-SSG, Pinia Colada / TanStack Query for Vue | Static generation and data fetching |