How Reactivity Works in Vue 3
What is reactivity?
In the context of Vue, reactivity is the ability to track changes in data and efficiently update the user interface (UI).
When you declare reactive data, Vue turns it into reactive state and associates it with dependencies that need to be notified when that data changes.
Vue 3 uses Proxies to implement reactivity. A Proxy is a JavaScript feature that allows intercepting and redefining operations such as reading, writing, or deleting properties on an object.
Simple Proxy example
In Vue 3, this same principle is applied to transform objects declared with reactive or ref into reactive structures.
Types of reactivity in Vue 3
Reactivity with reactive
The reactive method converts an object into a reactive proxy. Every time you access or modify its properties, Vue records dependencies and notifies affected components.
Reference-based reactivity with ref
ref is used to create simple reactive values, such as primitives or data structures that do not need to be complex objects.
Vue uses an internal system that tracks dependencies when reactive properties are accessed. This happens in the context of a reactive function such as computed or watchEffect.
Reactivity lifecycle
- Creation: Initial data is wrapped in proxies through
reactiveorref. - Tracking: When data is accessed inside a reactive context, Vue records the relationship between the data and the associated effect, such as updating the UI.
- Notification: When data changes, Vue automatically notifies all associated effects so they can update.
For more information, you can check Vue's official documentation on Reactivity in Depth.




