beforeMount Before Mount
Last updated: 2026-10-22
beforeMount Before Mount
beforeMount runs right before the initial render — the render function is ready but no DOM exists yet.
| Group | Options: Rendering & Lifecycle |
|---|---|
| Kind | Option |
| Scope | Component |
| Vue Version | 3.0+ |
| SSR Support | Yes |
📝 Syntax
export default {
beforeMount() {
// render ready, DOM not created
}
}
⚙️ Arguments
| value | No arguments |
|---|
Returns:No return value
▶ Example
Edit the code below and see the live result:
Output:
Shows 'ref at beforeMount: null'.
💡 Key Points
⚠️ Warning Do not read the DOM here — nothing is rendered yet.
ℹ️ Note The options counterpart of onBeforeMount, rarely needed.
🏷️ Related Rendering & Lifecycle
💡 Related Cases
More case studies coming soon.
📚 Related Tutorials
❓ FAQ
Q How is it different from created?
A created is earlier; beforeMount comes after the render function is prepared.
Q Are template refs available?
A No — they are null until mounted.
Q Is it needed day to day?
A Rarely — use created/setup and mounted instead.