π Vue.js Framework Overview
You've built UIs with plain JavaScript and with React. Now meet Vue β the framework famous for being the friendliest way into modern component-based development. This lesson gives you the mental model of what Vue is, why teams choose it, and how it stacks up against the tools you already know.
π― Learning Objectives
By the end of this lesson, you will be able to:
- Explain what Vue.js is and what "progressive framework" means in practice
- Describe Vue's reactivity and component models at a conceptual level
- Compare Vue against React and Angular on syntax, structure, and philosophy
- Identify the key pieces of the Vue ecosystem (Vite, Vue Router, Pinia, Nuxt)
- Scaffold a new Vue 3 project and read a Single-File Component
Estimated Time: 30β40 minutes β’ Difficulty: BeginnerβIntermediate
Hands-on: Scaffold a Vue 3 app with Vite and read your first Single-File Component.
In This Lesson
What Is Vue.js?
Vue.js (pronounced like "view") is an open-source JavaScript framework for building user interfaces and single-page applications. It was created by Evan You in 2014, after he worked with Angular at Google and wanted something lighter β keeping the parts he loved while shedding the ceremony.
"I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight."
β Evan You, creator of Vue.js
At its heart, Vue does one job extraordinarily well: it keeps what the user sees on screen in sync with your application's data. You describe what the UI should look like for a given state, change the state, and Vue efficiently updates the DOM for you. You never hand-write document.querySelector(...) plumbing again.
π Key Terms
Framework: a structured toolset that provides conventions and building blocks so you write less boilerplate.
Reactivity: the mechanism by which the UI automatically re-renders when the data it depends on changes.
Component: a reusable, self-contained piece of UI bundling its template, logic, and styles.
SPA (Single-Page Application): a web app that loads once and updates the view with JavaScript instead of full page reloads.
The "Progressive" Idea
Vue calls itself a progressive framework. That phrase is the key to understanding it. Unlike a monolithic framework that demands you commit to its whole world on day one, Vue is designed to be adopted incrementally. You can start small and scale up only as your needs grow.
- Drop-in enhancement β add a single
<script>tag to sprinkle interactivity onto one section of an existing server-rendered page. - Single-page application β add Vue Router and build a full client-side app with multiple views.
- Full-stack framework β reach for Nuxt when you need server-side rendering, file-based routing, and SEO.
π‘ Analogy: Vue is like a modular kitchen. You can buy just the mixing bowl today, add the stand mixer next month, and eventually build out the whole professional kitchen β without ever throwing away what you started with.
This is why Vue feels approachable: you never have to learn everything at once. Its core philosophy pulls in the same direction β approachable, versatile, performant, and maintainable.
How Vue Works Inside
You don't need to memorize Vue's internals to use it, but a mental picture of the pipeline makes everything that follows click into place. When your data changes, a chain of systems cooperates to update the screen with the minimum necessary work.
The reactivity system
Vue 3 wraps your state in JavaScript Proxies. When a component reads a piece of data during rendering, Vue quietly records that dependency. When that data later changes, Vue knows exactly which components need to re-render β and leaves everything else untouched.
π§ Analogy: Think of a smart irrigation system that senses which specific plants are dry and waters only those beds, instead of soaking the whole garden every time.
The component system
Vue apps are trees of components. Each component owns its own markup, behavior, and styling, and can be composed with others like building blocks.
π§± Analogy: Components are LEGO bricks β standardized, reusable pieces you snap together to build something far bigger than any single brick.
The Virtual DOM
Rather than rewriting the whole page on every change, Vue keeps a lightweight in-memory copy of the DOM. When state changes, it builds a new virtual tree, diffs it against the old one, and applies only the differences to the real DOM.
π Analogy: An architect doesn't demolish and rebuild a house for a small remodel. They compare the existing structure to the new blueprint and change only the rooms that differ.
The Single-File Component
The signature way to write Vue is the Single-File Component (SFC): a .vue file that keeps a component's template, logic, and styles together in one place. Modern Vue 3 uses the Composition API with <script setup>, which is the concise, recommended style you'll use throughout this module.
<script setup>
import { ref, computed } from 'vue'
// `ref` creates a reactive value
const count = ref(0)
// a computed value updates automatically when `count` changes
const doubled = computed(() => count.value * 2)
function increment() {
count.value++
}
</script>
<template>
<button @click="increment">Clicked {{ count }} times</button>
<p>Doubled: {{ doubled }}</p>
</template>
<style scoped>
button {
font-size: 1rem;
padding: 0.5rem 1rem;
}
</style>
Three blocks, one file:
<script setup>β the component's reactive state and behavior. Anything declared here is available to the template automatically.<template>β HTML enhanced with Vue's binding syntax ({{ }},@click, and more).<style scoped>β CSS that applies only to this component, thanks to thescopedattribute.
π‘ Note on .value
Inside <script>, a ref is an object, so you read and write it through its .value property (count.value++). Inside the <template>, Vue unwraps it for you β you write just {{ count }}. This distinction trips up every newcomer once; after that it becomes muscle memory.
Vue vs React vs Angular
All three are excellent, production-proven tools that solve the same core problem. Choosing between them is more about team, ecosystem, and taste than about capability. Here's an honest side-by-side.
| Aspect | Vue | React | Angular |
|---|---|---|---|
| Type | Progressive framework | Library (UI only) | Full framework |
| UI syntax | HTML templates (JSX optional) | JSX | HTML templates |
| Reactivity | Automatic (Proxy tracking) | Manual (hooks & re-render) | Signals / Zone.js |
| Language | JS or TypeScript | JS or TypeScript | TypeScript (required) |
| Learning curve | Gentle | Moderate | Steep |
| Built-in tooling | Router & store are official add-ons | Community-chosen | Batteries included |
β You already know most of this
Because you've learned React, Vue will feel like a familiar idea with a friendlier syntax. Components, props, state, and a Virtual DOM all carry over. The biggest shift is that Vue's reactivity is automatic: you rarely think about dependency arrays or manual re-renders.
The Vue Ecosystem
Vue's core stays small on purpose. Around it sits a set of officially maintained libraries that you add when a project needs them.
| Tool | Role | When you reach for it |
|---|---|---|
| Vite | Build tool & dev server | Every modern Vue project β instant startup and hot reload |
| Vue Router | Client-side routing | Multi-page single-page apps |
| Pinia | State management | Sharing state across many components (successor to Vuex) |
| Nuxt | Full-stack meta-framework | Server-side rendering, SEO, file-based routing |
| Vue DevTools | Browser debugging extension | Inspecting component trees and reactive state |
Vue is trusted in production by companies across many industries β Alibaba and Nintendo in e-commerce, GitLab and Adobe in enterprise tooling, and countless dashboards and internal tools where a gentle learning curve helps teams move fast.
Getting Started
There are two realistic ways to begin, depending on your goal.
Option A β quick experiment via CDN
Perfect for a throwaway prototype or enhancing a plain HTML page. No build step required:
<div id="app">{{ message }}</div>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
const { createApp, ref } = Vue
createApp({
setup() {
const message = ref('Hello Vue!')
return { message }
}
}).mount('#app')
</script>
Option B β a real project with Vite (recommended)
For anything you intend to keep, scaffold a proper project. The official create-vue tool sets up Vite, optional TypeScript, Vue Router, and Pinia for you:
npm create vue@latest my-app
cd my-app
npm install
npm run dev
Terminal output
VITE v5.x ready in 312 ms
β Local: http://localhost:5173/
β press h + enter to show help
Open that URL and you have a live, hot-reloading Vue 3 app. Every change you save appears in the browser almost instantly.
Hands-on Exercise
ποΈ Scaffold and Read Your First Vue App
Objective: Create a Vue 3 project with Vite and understand what the starter Single-File Component is doing.
Instructions:
- Run
npm create vue@latest hello-vue. Accept the defaults (you can say "No" to every extra feature for now). cd hello-vue, thennpm install, thennpm run dev.- Open
src/components/HelloWorld.vueand identify its three blocks:<script setup>,<template>, and<style>. - Change the
refvalue or a piece of template text, save, and watch the browser update without a manual refresh.
π‘ Hint
The starter HelloWorld.vue declares something like const count = ref(0) and renders a button with @click="count++". Try changing the initial value to 10 and confirm the button now starts counting from there.
β A minimal component to compare against
<script setup>
import { ref } from 'vue'
const name = ref('Ray')
const showMessage = ref(false)
</script>
<template>
<h1>Hello, {{ name }}!</h1>
<button @click="showMessage = !showMessage">
Toggle message
</button>
<p v-if="showMessage">You just used your first Vue directive.</p>
</template>
This uses a ref for data, an @click event handler, and a v-if directive β the exact tools the next lesson covers in depth.
π― Quick Quiz
Question 1: What does it mean that Vue is a "progressive framework"?
Question 2: In a Single-File Component using <script setup>, how do you read a ref called count inside JavaScript?
Question 3: Which tool is the modern, recommended way to build and serve a new Vue 3 project?
Best Practices
β Do
- Start new projects with Vue 3 + Composition API +
<script setup>. - Use Vite for the dev server and build.
- Reach for Pinia (not Vuex) when you need shared state.
- Keep components small and focused on one responsibility.
β οΈ Don't
- Don't start greenfield projects on the Options API or Vue 2 β you'll read them in legacy code, but write new code the modern way.
- Don't forget
.valuewhen reading or writing a ref inside<script>. - Don't pull in Nuxt or a router before your project actually needs them β stay progressive.
Summary & Quiz
π Key Takeaways
- Vue is a progressive JavaScript framework for building reactive user interfaces.
- Its reactivity system (Proxy-based in Vue 3) and Virtual DOM update the screen efficiently when data changes.
- You write UI as Single-File Components using the Composition API and
<script setup>. - Vue sits between React's minimalism and Angular's completeness, and its concepts transfer directly from what you already know.
- Scaffold real projects with Vite via
npm create vue@latest.
π Further Reading
π What's Next?
Next we'll open the hood and work directly with the pieces we glimpsed here β creating a Vue instance, wiring up reactive data, and applying the built-in directives that make templates come alive.
π Nice work!
You've got the map of Vue in your head. Let's start building with it.