Let's break it down simply
ref() wraps a value in a reactive wrapper that you read and write via .value in JavaScript. reactive() turns an object into a proxy. In the template, you can use a ref directly — no .value needed.
vue
<script setup>
import { ref, reactive } from 'vue'
const count = ref(0)
const user = reactive({ name: 'Aye Aye', points: 10 })
function addPoint() {
count.value++
user.points += 5
}
</script>
<template>
<button @click="addPoint">Clicks: {{ count }}</button>
<p>{{ user.name }} — {{ user.points }} points</p>
</template>You should see
Clicks: 1
Aye Aye — 15 pointsTry it yourself
Store a shopping cart quantity in a ref and change it with two +/− buttons.
Reactivity Fundamentals — Vue.js