reactive() Create a Reactive Object Proxy

Last updated: 2026-10-22

reactive() Create a Reactive Object Proxy

reactive() wraps an object or array in a deep reactive proxy — reading and writing properties directly triggers updates.

GroupReactivity: Core
KindAPI
ScopeComponent
Vue Version3.0+
SSR SupportYes

📝 Syntax

const state = reactive({ count: 0 })
state.count++        // read/write directly, no .value

⚙️ Arguments

targetAn object, array or collection such as Map/Set

Returns:A reactive proxy of the original object; both share the same data

▶ Example

Edit the code below and see the live result:

Output:

Shows 'Count: 0'; each click increments it.

💡 Key Points

⚠️ Warning Objects and arrays only — primitives lose reactivity, use ref() there.
⚠️ Warning Destructuring breaks reactivity: use toRefs(state) or keep state.count.
ℹ️ Note Replacing the whole object cuts the proxy link — ref handles wholesale replacement better.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q reactive or ref — which one?
A Prefer ref by default: any type, replaceable, safe to destructure. Use reactive when object-style state reads best.
Q Why does mutating state.x update the page?
A The Proxy traps reads and writes, collecting dependencies on read and notifying on write.
Q How does the proxy relate to the original object?
A They share the same data; the proxy simply adds reactivity tracking.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏