Back
VueHardNew

What is the difference between `watch` with `deep: true` and just watching a reactive object directly?

reactive() objects are deeply watched implicitly; refs to objects need { deep: true }

Ideal Answer

When watching a reactive() object directly, Vue implicitly performs a deep watch — nested property changes trigger the callback automatically.

JavaScript
const state = reactive({ user: { name: 'A' } })
watch(state, () => console.log('changed')) // deep by default

When watching a ref that holds an object, however, Vue only watches .value reassignment by default — nested mutations won't trigger the callback unless you explicitly pass { deep: true }:

JavaScript
const state = ref({ user: { name: 'A' } })
watch(state, () => console.log('changed'), { deep: true })

Deep watching can be expensive on large objects, so use it deliberately, or watch a specific getter function instead of the whole object when possible.