Lesson

Vue Intro

10 min reading
Free Course

Vue.js Introduction: Progressive Framework and Proxy-Based Reactivity

This Vue.js introduction explains what Vue is, why it is called a progressive framework, and how its reactivity system keeps your page in sync with your data. Vue is an open-source JavaScript framework for building user interfaces and single-page applications. You can add it to an existing HTML page with one script tag, or build a full project with Vite, Vue Router, and Pinia.

"Progressive" means you adopt only what your project needs. A beginner can start with an HTML template and a few reactive variables, then move to components and tooling as the app grows.

How Vue 3 Reactivity Works

When your data changes, Vue updates the page for you. The steps look like this:

  1. Your code changes a piece of reactive state.

  2. Vue's reactivity layer, built on ES6 Proxy, notices the change.

  3. Vue knows which components used that value during rendering, because it tracked those reads earlier.

  4. Those components re-render into a virtual DOM, a lightweight JavaScript description of the page.

  5. Vue compares the new description with the old one and patches only the parts of the real DOM that differ.

You never write the DOM update yourself. You describe what the page should look like for a given state, and Vue handles the rest.

Core Features of Vue 3

  • Declarative rendering. Templates use mustache syntax ({{ }}) to display state, so the HTML always reflects your data.

  • Proxy-based reactivity. Vue 3 wraps reactive data in Proxies, so only the components that depend on a changed value need to update.

  • Single File Components (SFCs). A .vue file keeps markup, <script setup> logic, and scoped CSS together.

  • Batched updates. Vue groups several state changes into one render pass instead of touching the DOM after each assignment.

A Practical Vue 3 Component Example

In <script setup>, top-level imports, variables, and functions are available directly inside <template>. Clicking the button below changes the count value, and Vue updates the paragraph on its own.

<script setup>
import { ref } from 'vue';

const title = ref('Welcome to Vue 3');
const count = ref(0);

function increment() {
  count.value++;
}
</script>

<template>
  <div class="card">
    <h2>{{ title }}</h2>
    <p>Current count: <strong>{{ count }}</strong></p>
    <button @click="increment">Increment Counter</button>
  </div>
</template>

<style scoped>
.card {
  padding: 1.5rem;
  border-radius: 8px;
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
}
button {
  background-color: #42b883;
  color: #ffffff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}
</style>

Run It Locally

The official scaffolding tool, create-vue, sets up a Vite project for you. You need a current LTS version of Node.js first.

npm create vue@latest
cd your-project-name
npm install
npm run dev

Open the local address Vite prints, paste the component into src/App. vue,vue, and click the button. If the number goes up with each click, your setup works. The official Vue quick start lists the current prompts and requirements.

Try Vue Without a Build Step

For a quick experiment, load Vue from a CDN in a plain HTML file:

<div id="app">
  <p>Count: {{ count }}</p>
  <button @click="count++">Add one</button>
</div>

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
  const { createApp, ref } = Vue;
  createApp({
    setup() {
      const count = ref(0);
      return { count };
    }
  }).mount('#app');
</script>

This is fine for prototypes and small enhancements. Use a CDN link pinned to a specific version in production, and switch to Vite when you need .vue files, hot reload, and optimized bundles.

Common Mistakes When Starting with Vue

  • Forgetting .value in script code. Inside <script setup>, a ref must be read and written through count.value. In the template, Vue unwraps top-level refs automatically, so you write {{ count }}. If a value never seems to change, check for a missing .value first.

  • Changing the DOM by hand. Calling document.querySelector to edit text or styles works against Vue. If the value lives in a ref, bind it in the template and let Vue render it.

  • Mixing Vue 2 and Vue 3 patterns. Code like new Vue({ el: '#app' }) is Vue 2 style. New projects should use createApp or SFCs with <script setup>. Many older tutorials still show the Vue 2 style, so check which version a guide targets.

For more on how components fit together, see our lessons on Vue components and Vue directives. For deeper reference, the Vue reactivity guide covers ref and reactive in detail.

Frequently Asked Questions

Do I need a build step to use Vue 3?

No, you can load Vue from a CDN script tag in a static HTML file. However, Vite gives you .vue Single File Components, fast hot reload, and smaller production bundles.

What is the difference between Options API and Composition API?

The Options API groups code by data, methods, and computed options. The Composition API with <script setup> groups code by feature using imported functions like ref and computed.

Why does Vue 3 use ES6 Proxies for reactivity?

ES6 Proxies detect property additions, deletions, and array index updates natively. This fixes reactivity edge cases that existed in Vue 2's Object.defineProperty approach.

Conclusion

Vue's main idea is simple: describe your interface as a function of your state, and let the framework keep the page current. Start with a single ref and a template, move to Vite and Single File Components once you want a real project, and add routing or shared state only when you need them. Your next step is building your first Vue component.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol
Lesson Recap Quiz Available

Test Your Knowledge

You've completed this section! Take a quick 5-question quiz to check your understanding.

Vue Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum