Skip to main content
InterviewHubPRO
Section Overview
Q3

Question 3 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

6%
Vue.js & Composition API (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What is the difference between `ref()` and `reactive()` in Vue 3?

junior LevelVue & Nuxt

In Simple Words:

  • ref(value):
    • Works with primitives (strings, numbers, booleans) as well as objects.
    • Wraps the value in a reactive container object with a .value property.
    • In <script setup>, you must access .value (count.value++); in <template>, Vue unwraps it automatically (<button>{{ count }}</button>).
  • reactive(object):
    • Works only with objects and arrays (cannot take primitives).
    • Returns a deeply reactive Proxy directly (no .value needed).
    • Risk: Destructuring a reactive object (const { x, y } = reactiveObj) destroys reactivity unless you use toRefs().
  • Industry Best Practice: Many teams standardize on using ref() exclusively for consistency.