Suggest an editImprove this articleRefine the answer for “What lifecycle hooks are available?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)Vue provides a **full set of lifecycle hooks**, but the set differs between the **Options API** and the **Composition API**. In the Options API these are `beforeCreate`, `created`, `beforeMount`, `mounted`, `beforeUpdate`, `updated`, `beforeUnmount`/`unmounted`, `activated`/`deactivated`. In the Composition API they have `on`-prefixed equivalents (`onMounted`, `onUpdated`, etc.), plus extra hooks like `onErrorCaptured`. **Key point:** in an interview it matters to list both sets - for the Options API and for the Composition API.Shown above the full answer for quick recall.Answer (EN)ImageVue provides a **full set of lifecycle hooks**, but the set differs between the **Options API** and the **Composition API**. In an interview it matters to list both sets. --- ## Lifecycle hooks in the Options API (Vue 2/3) This is the classic set: ### Initialization stage - **beforeCreate** - **created** ### Mounting stage - **beforeMount** - **mounted** ### Update stage - **beforeUpdate** - **updated** ### Unmounting stage - **beforeUnmount** *(Vue 3)* (in Vue 2 this is `beforeDestroy`) - **unmounted** *(Vue 3)* (in Vue 2 this is `destroyed`) ### Components inside `<keep-alive>` - **activated** - **deactivated** --- ## Lifecycle hooks in the Composition API (Vue 3) These hooks are imported from Vue and called inside `setup()` or `<script setup>`: ```js import { onMounted, onUpdated, onUnmounted } from 'vue' ``` ### Initialization - **onBeforeMount** - **onMounted** ### Update - **onBeforeUpdate** - **onUpdated** ### Unmounting - **onBeforeUnmount** - **onUnmounted** ### Keep-alive hooks - **onActivated** - **onDeactivated** ### Additional - **onErrorCaptured** - catches errors in child components - **onRenderTracked** - reactivity debugging - **onRenderTriggered** - shows what caused a recalculation - **onServerPrefetch** - for SSR - **onScopeDispose** - cleanup inside composables --- ## Summary (great for an interview) ### **Options API** ``` beforeCreate created beforeMount mounted beforeUpdate updated beforeUnmount (beforeDestroy) unmounted (destroyed) activated deactivated ``` ### **Composition API** ``` onBeforeMount onMounted onBeforeUpdate onUpdated onBeforeUnmount onUnmounted onActivated onDeactivated onErrorCaptured onRenderTracked onRenderTriggered onServerPrefetch onScopeDispose ```For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.