List all the lifecycle hooks.
Lifecycle hooks - Options API (Vue 2 and Vue 3)
Initialization
- beforeCreate
- created
Mounting
- beforeMount
- mounted
Updating
- beforeUpdate
- updated
Unmounting
- beforeUnmount (Vue 3) (in Vue 2, beforeDestroy)
- unmounted (Vue 3) (in Vue 2, destroyed)
Working with <keep-alive>
- activated
- deactivated
Error handling
- errorCaptured
Lifecycle hooks - Composition API (Vue 3)
Imported from vue:
js
import {
onBeforeMount,
onMounted,
onBeforeUpdate,
onUpdated,
onBeforeUnmount,
onUnmounted,
onActivated,
onDeactivated,
onErrorCaptured,
onRenderTracked,
onRenderTriggered,
onServerPrefetch,
onScopeDispose
} from 'vue'Mounting
- onBeforeMount
- onMounted
Updating
- onBeforeUpdate
- onUpdated
Unmounting
- onBeforeUnmount
- onUnmounted
Working with <keep-alive>
- onActivated
- onDeactivated
Errors
- onErrorCaptured
Reactivity debugging
- onRenderTracked
- onRenderTriggered
SSR
- onServerPrefetch
Cleanup in composables
- onScopeDispose
Important for interviews
- The Options API and Composition API have different hook chains.
- In Vue 3, the unmounting hooks have new names: beforeUnmount / unmounted instead of beforeDestroy / destroyed.
- The Composition API has more hooks, especially for debugging and SSR.
Final list (short)
Options API:
beforeCreate
created
beforeMount
mounted
beforeUpdate
updated
beforeUnmount (beforeDestroy)
unmounted (destroyed)
activated
deactivated
errorCapturedComposition API:
onBeforeMount
onMounted
onBeforeUpdate
onUpdated
onBeforeUnmount
onUnmounted
onActivated
onDeactivated
onErrorCaptured
onRenderTracked
onRenderTriggered
onServerPrefetch
onScopeDisposeShort Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.