app.mount() Mount the App
Last updated: 2026-10-22
app.mount() Mount the App
app.mount() attaches the app to a container element, replacing its inner DOM with the app's render output.
| Group | Global API |
|---|---|
| Kind | API |
| Scope | Global |
| Vue Version | 3.0+ |
| SSR Support | Yes |
📝 Syntax
app.mount("#app")
// element reference also works
app.mount(document.getElementById("app"))
⚙️ Arguments
| rootContainer | A CSS selector or a real element |
|---|
Returns:The root component instance
▶ Example
Edit the code below and see the live result:
Output:
Shows 'mounted' and logs the root instance.
💡 Key Points
⚠️ Warning Container contents get replaced — do not rely on them as templates.
ℹ️ Note The return value is the root instance.
💡 Tip Re-mounting on the same element warns.
🏷️ Related Global API
💡 Related Cases
More case studies coming soon.
📚 Related Tutorials
❓ FAQ
Q Can I mount on body?
A Avoid it — use a dedicated container.
Q Can I access the instance before mounting?
A No — use the returned instance after mounting.
Q Can one app mount twice?
A One mount per app.