shallowReactive() Shallow Reactive Object

Last updated: 2026-10-22

shallowReactive() Shallow Reactive Object

shallowReactive() makes only the first level of properties reactive; nested objects stay unproxied.

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

📝 Syntax

const state = shallowReactive({ count: 0, nested: { a: 1 } })
state.count++         // ✅ triggers
state.nested.a++      // ❌ no trigger

⚙️ Arguments

targetAn object (only its own properties are proxied)

Returns:A shallow reactive proxy

▶ Example

Edit the code below and see the live result:

Output:

The top-level button updates the number; the nested one changes data without refreshing the view.

💡 Key Points

ℹ️ Note Same niche as shallowRef: large structures where only the first level matters.
⚠️ Warning Missing updates does not mean unchanged data — a common pitfall.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q Is it only a performance difference?
A No — nested state is not reactive either; it is a semantic difference.
Q Can nested objects still be watched?
A Only with explicit deep watching or a deep ref wrapper.
Q Why does it exist?
A To provide a low-overhead reactive shell over large or external data.
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%

🙏 帮我们做得更好

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

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