Skip to content
Web Development

Vue Tutorial for Beginners: Vue.js 3 Step by Step

Learn Vue.js 3 step by step: create a project, build single-file components, use reactive state with the Composition API and add routing and state management.

Vue tutorial: code editor with Vue code on a widescreen monitor, dark theme
Quick answer

Vue.js is a progressive JavaScript framework for building user interfaces. Create a project with npm create vue@latest (it uses Vite), write single-file components (.vue files with template, script and style), manage reactive data with ref() and computed() in the Composition API, and add Vue Router for pages and Pinia for shared state. Use Nuxt for server-rendered Vue sites.

Vue is known for its gentle learning curve and excellent documentation. You can add it to a single page or build a full application. This tutorial uses Vue 3.

Create a Vue project

01

Install Node.js

Use a current LTS version.

02

Scaffold the project

Run npm create vue@latest and choose options such as TypeScript, Vue Router and Pinia.

03

Install and run

Run npm install then npm run dev and open the local URL shown.

Your first component

A single-file component keeps the template, logic and styles together. The <script setup> syntax is the recommended way to use the Composition API.

<script setup>
import { ref, computed } from 'vue'

const name = ref('World')
const count = ref(0)
const message = computed(() => `Hello, ${name.value}! Clicked ${count.value} times.`)
</script>

<template>
  <input v-model="name" placeholder="Your name">
  <button @click="count++">Click me</button>
  <p>{{ message }}</p>
  <ul>
    <li v-for="n in count" :key="n">Click {{ n }}</li>
  </ul>
</template>

<style scoped>
button { padding: .5rem 1rem; }
</style>

Core Vue concepts

ConceptWhat it does
Template syntax{{ }} for text, v-bind (:) for attributes, v-on (@) for events
Directivesv-if, v-for, v-model and more
Reactivityref() and reactive() update the UI when data changes
Computed and watchersDerived values and side effects
Props and emitsPass data into components and send events out
Vue RouterClient-side pages and navigation
PiniaThe official state management library
NuxtA Vue framework for server rendering, static sites and SEO

Options API vs Composition API

Vue supports two styles. The Options API groups code by data, methods and computed properties — familiar for beginners. The Composition API groups code by feature and makes logic easier to reuse with composables. New projects usually use the Composition API with <script setup>.

Vue vs React

Vue uses HTML-based templates and has official solutions for routing and state, while React uses JSX and leaves more choices to you. Both are excellent. See React vs Vue and our React tutorial.

Tip: Building a content site or blog with Vue? Use Nuxt so pages are rendered on the server or generated as static HTML for better SEO.

A practice project: a filtered list

<script setup>
import { ref, computed } from "vue";

const query = ref("");
const guides = ["HTML basics", "CSS Grid", "JavaScript arrays", "Vue components"];
const results = computed(() =>
  guides.filter(g => g.toLowerCase().includes(query.value.toLowerCase()))
);
</script>

<template>
  <label>Search <input v-model="query" type="search"></label>
  <ul v-if="results.length">
    <li v-for="g in results" :key="g">{{ g }}</li>
  </ul>
  <p v-else>No guides found.</p>
</template>

v-model keeps the input and query in step. computed works out the list again only when something it uses changes. Try adding a category filter, then move the list into its own component.

Common mistakes

Keep learning

More in Web Development

HTML

Learn how HTML structures modern websites — from document basics and semantic elements to forms, media, accessibility, SEO and practical…

CSS

Learn how CSS controls the appearance, layout, responsiveness and visual behaviour of modern websites — from selectors and the box…

JavaScript

Learn JavaScript from the fundamentals to DOM manipulation, events, functions, asynchronous programming, APIs, modules, browser storage and modern frontend development.

PHP

Learn PHP from the fundamentals to server-side programming, forms, databases, APIs, object-oriented programming, WordPress development, security and modern backend development.

React

Learn React from the fundamentals to components, JSX, props, state, hooks, forms, APIs, performance, accessibility, testing and modern frontend application…

Angular

A beginner-friendly Angular tutorial: what Angular is, how components, signals and services work, how to start a project and when…

Next.js

Learn Next.js step by step: the App Router, Server Components, rendering options, metadata for SEO, images and how to build…

Laravel

Learn Laravel from PHP framework fundamentals and MVC architecture to routing, controllers, Blade, Eloquent, databases, APIs, authentication, security, testing, performance…

Latest articles

Related Web Development articles

FAQ

Vue tutorial: your questions answered

Short, honest answers to the questions people ask most about this topic.

Is Vue easier than React?

Many beginners find Vue easier because templates look like HTML and the framework includes official routing and state tools. React has a larger ecosystem and job market. Both are good choices.

No. Vue 2 reached end of life at the end of 2023. New projects should use Vue 3.

Nuxt is a framework built on Vue that adds file-based routing, server-side rendering, static site generation and SEO features, similar to what Next.js does for React.

Yes. Vue can power interactive parts of WordPress or Laravel sites, or act as a separate frontend that consumes their APIs.

Next step

Keep building your skills

Explore the rest of our Web Development guides, or follow the beginner path step by step.