Skip to main content
InterviewHubPRO
HomeTracksSection 5: Vue.js & Composition API (50 Qs)
Section 5 of 6450 Questions (1 Per Page)

Vue.js Core Architecture, Composition API & Reactivity Engine Master Interview Bank

Vue Proxy-based reactivity engine (ref, reactive, effectScope), Composition API, Vapor Mode (VDOM-less compilation), Pinia state architecture, and hydration.

Curriculum Roadmap & Learning Path

3 Stages
Tip: Click any stage card above to instantly filter the question bank to that topic.3 Connected Milestones
50 of 50 Qs

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

12 Questions
1
Junior#Vue & Nuxt#HTTP & REST APIs

What is Vue 3 and what are the main differences between the Options API and Composition API?

Options API (Vue 2 & Vue 3 Legacy) • Code is split across predefined options blocks: data(), methods, computed, watch, mounted() • Limitation: In complex components, logic for a single feature (e.g. user search) is fragmented across 5 different options blocks, forcing • Composition API (Vue 3 Modern Standard).

2
Junior#Vue & Nuxt

How does Vue 3's Proxy-based Reactivity System work compared to Vue 2?

Vue 2 (Object.defineProperty) • Intercepted properties using getters and setters • Severe Limitations: Could not detect dynamically added or deleted properties (this.obj.newProp = 123 required Vue.set()), and could not detect • Vue 3 (Proxy).

3
Junior#Vue & Nuxt

What is the difference between `ref()` and `reactive()` in Vue 3?

ref(value) • Works with primitives (strings, numbers, booleans) as well as objects • Wraps the value in a reactive container object with a .value property • In , you must access .value (count.value++); in , Vue unwraps it automatically ({{ count }}).

4
Junior#Signals#Vue & Nuxt

How do `computed()` and `watch()` work in Vue 3?

computed(() => ...) • Derives a new reactive value from existing state • Cached: Recomputes only when its reactive dependencies change • Read-only by default (can define custom getter/setter).

5
JuniorCode#Signals

What is `watchEffect()` and how does it differ from `watch()`?

watch(source, cb) • You must explicitly define what state to watch (watch(userId...)) • Separates the watched dependency from the side effect • watchEffect(cb).

6
Junior#vue#Basic

What is the `<script setup>` syntax sugar?

`` is the compiled syntactic sugar for using the Composition API inside Single-File Components (SFCs): No boilerplate: Top-level variables, functions, and imports are automatically exposed to the template without an explicit export default {.

7
Junior#Hooks#Lifecycle

What are the essential Vue 3 Lifecycle Hooks?

In the Composition API, lifecycle hooks are imported and invoked inside setup(): onMounted(): Component has finished initial rendering and DOM nodes are accessible • onUpdated(): DOM has updated following a reactive state mutation • onUnmounted(): Component has been destroyed and removed from DOM.

8
JuniorCode#Components

How does Two-Way Data Binding work with `v-model` and `defineModel()`?

In Vue 2: v-model was limited to a single property (value + input event) • In Vue 3: A component can have multiple v-model bindings.

9
JuniorCode#Components

What are `defineProps` and `defineEmits` in `<script setup>`?

Compiler macros (no need to import them!) used to declare component API contracts.

10
Junior#Forms#Performance

`v-if` vs. `v-show`: Performance and DOM Differences.

v-if (Conditional Rendering) • "Real" conditional rendering: elements are physically added or removed from the DOM • Destroys and recreates child component instances and triggers lifecycle hooks (onMounted / onUnmounted) • High toggle cost; low initial render cost if condition is false.

11
JuniorCode#Vue & Nuxt

How do Slots, Named Slots, and Scoped Slots work in Vue 3?

Default Slot: Injects child content (``) • Named Slots (#name): Injects content into specific slots.

12
JuniorCode#Components

What is the native `<Teleport>` component?

Allows you to render a component's DOM subtree into a different location in the DOM outside the component hierarchy (typically body), while preserving the component's logical parent-child state and event communication.

Part 2: Core Architecture & Implementation (Mid-Level)

12 Questions
13
SeniorCode#State Management#System Design

What is Pinia and why did it replace Vuex?

Pinia is the official state management library for Vue 3: No Mutations: In Vuex, modifying state required writing verbose mutations and actions • First-Class TypeScript: 100% type-safe autocomplete without magic strings or complex generic wrappers.

14
SeniorCode#System Design#Vue & Nuxt

How do you structure Composables in Vue 3?

A Composable is a function that leverages Vue's Composition API to encapsulate and share stateful logic.

15
SeniorCode#Components#System Design

What are Template Refs in the Composition API?

Direct access to rendered DOM elements or child component instances.

16
Most AskedSeniorCode#Dependency Injection#System Design

Dependency Injection with `provide()` and `inject()`.

Passes state from an ancestor component down to deeply nested children without prop drilling.

17
SeniorCode#Hooks#Lifecycle

What is `<KeepAlive>` and its lifecycle hooks?

Caches inactive component instances in memory rather than destroying them when switching views.

18
SeniorCode#Directives#System Design

What are Custom Directives in Vue 3?

Low-level DOM manipulation abstractions.

19
Senior#Forms#Performance

Optimizing Performance with `shallowRef()` and `shallowReactive()`.

Standard ref() and reactive() recursively convert all nested properties into Proxies. If you fetch a massive array of 50,000 read-only table records from an API: Deep reactivity creates 500,000 Proxies, burning memory and freezing the browser • shallowRef(massiveArray): Only tracks .value reassignment.

20
Most AskedSeniorCode#System Design#Databases & SQL

What is `v-memo` and how does it optimize virtual DOM sub-tree updates?

Introduced in Vue 3.2, v-memo="[dep1, dep2]" memoizes a chunk of the template.

21
SeniorCode#System Design#Vue & Nuxt

Preserving Reactivity: `toRef()`, `toRefs()`, and `toValue()`.

Destructuring a reactive object breaks reactivity: const { count } = state; -> loses proxy connection! • toRefs(state): Converts every property into an independent ref that stays linked to the source object.

22
Senior#System Design

Transitions: `<Transition>` and `<TransitionGroup>`.

Applies automated CSS enter/leave animation classes: Classes applied automatically: v-enter-from, v-enter-active, v-enter-to, v-leave-from, v-leave-active, v-leave-to • TransitionGroup: Handles lists with smooth positional layout transitions via FLIP animations (v-move).

23
SeniorCode#Components#Async & Promises

Async Components (`defineAsyncComponent`).

Lazy-loads components on-demand using dynamic imports.

24
SeniorCode#Routing#System Design

Vue Router 4 Composition API Integration.

```typescript import { useRouter, useRoute } from 'vue-router'; const router = useRouter(); // Programmatic navigation const route = useRoute(); // Reactive params and query function handleSearch() { router.push({ path: '/search', query: { q: 'vue' } }); }.

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

26 Questions
25
SeniorCode#System Design#Vue & Nuxt

Deep Dive into Vue 3 Reactivity Internals: `track()`, `trigger()`, and `TargetMap`.

Under the hood, Vue's reactivity engine uses a global WeakMap.

26
SeniorCode#Performance#System Design

Vue 3 Compiler Optimizations: Block Tree and Patch Flags.

Unlike React (which diffs the entire Virtual DOM tree blindly), Vue 3 analyzes templates at compile-time: Patch Flags: The compiler tags dynamic bindings with binary bitmasks.

27
Senior#System Design#HTTP & REST APIs

Custom Renderers: The `createRenderer` API.

Vue 3 separates the core runtime from the browser DOM: You can create custom renderers targeting Canvas, WebGL (TresJS), Terminal CLI (Ink-like), or Native Mobile by implementing standard node ops.

28
SeniorCode#State Management#SSR & Hydration

Managing Enterprise Pinia Stores: Plugins and SSR Hydration.

Pinia Plugins: Global interceptors for state persistence (localStorage) or telemetry.

29
Senior#Memory Management#System Design

Memory Leak Prevention in Long-Running Vue 3 SPAs.

Unregistered Listeners: Always remove window event listeners in onUnmounted • Third-Party Libraries: Explicitly call .destroy() on Chart.js, TinyMCE, or Leaflet map instances in onUnmounted • Uncleared Watchers: Watchers created outside of component setup() must be stopped manually by calling the returned unwatch function.

30
SeniorCode#System Design#Vue & Nuxt

Error Handling in Vue 3: `onErrorCaptured` and Global Handlers.

onErrorCaptured: Component-level error boundary • Global Handler.

31
Senior#Forms#Performance

Performance Benchmarks: Vue 3 vs. Svelte 5 vs. React 19.

Vue 3: Hybrid model • Svelte 5: No Virtual DOM • React 19: Full VDOM diffing with Fiber concurrency.

32
SeniorCode#Components#Testing

Testing Vue 3 Components with Vitest and `@vue/test-utils`.

Testing Vue 3 components with Vitest and @vue/test-utils mounts the component in a virtual DOM, provides mock props, dispatches user interaction events, and asserts reactive DOM mutations. #### Code Example.

33
SeniorCode#TypeScript#System Design

TypeScript Generics in `<script setup lang="ts">`.

Generic components (e.g. a reusable ``).

34
SeniorCode#System Design#Vue & Nuxt

Microfrontends with Vue 3.

Package Vue 3 components as standard Web Components using defineCustomElement().

35
Senior#Forms#Performance

The 10 Principles of High-Performance Enterprise Vue 3 Architecture.

Standardize on `` and Composition API • Use shallowRef for large read-only datasets • Leverage v-memo in long list renders • Prefer Pinia Setup Stores over Options Stores.

36
SeniorCode#System Design#Vue & Nuxt

Vue 3 `toRef` vs `toRefs` vs `toValue`: Deep Dive into Reactivity Utilities.

toRef: Creates a ref tracking a single property from a reactive object or converts a getter/value into a ref • toRefs: Converts all properties of a reactive object into individual refs, preserving reactivity when destructuring.

37
SeniorCode#Directives#Hooks

Custom Directives in Vue 3: Lifecycle Hooks and Practical Implementations.

Custom Directives allow direct low-level DOM manipulations on elements. In Vue 3, directive hooks mirror component lifecycles (created, beforeMount, mounted, beforeUpdate, updated, beforeUnmount, unmounted).

38
SeniorCode#System Design#Vue & Nuxt

Vue 3 Reactivity Caveats: Loss of Reactivity During Destructuring and How to Preserve It.

Destructuring properties from a reactive() object strips their reactive link because JavaScript passes primitive values (number, string, boolean) by value, not by reference.: The Problem: Destructuring const { count } = reactive({ count: 0 }) creates an isolated primitive local variable that never updates when the.

39
SeniorCode#System Design#Vue & Nuxt

`v-model` Modifiers in Vue 3: Built-in vs Custom Modifier Implementation.

v-model modifiers adjust how user input is bound to component state.: Built-in Modifiers.lazy (syncs on change event instead of input).number (typecasts input string to number via parseFloat).trim (strips • Custom Modifiers: Accessed via defineProps() in child components.

40
SeniorCode#System Design#Vue & Nuxt

Vue 3 `defineModel` Macro (Vue 3.4+): Two-Way State Binding.

defineModel eliminates boilerplate prop/emit pairings for v-model. Previously, two-way binding required declaring defineProps(['modelValue']) and defineEmits(['update:modelValue']). With defineModel, the compiler automatically handles the prop declaration and event emission as a synchronous ref.

41
SeniorCode#System Design#Vue & Nuxt

Vue 3 Slots Deep Dive: Default, Named, Scoped Slots, and Dynamic Slot Names.

Default Slot: Injects content without a name (`) • Named Slots: Target specific outlets () using • Scoped Slots: Pass data from child up to parent template (`), allowing parents to customize render logic while children control data loops.

42
SeniorCode#Components#State Management

`provide` / `inject` vs Pinia: Patterns for Hierarchical Component Trees.

provide / inject: Dependency injection across parent-to-deep-child ancestor trees • Pinia: Global application state with devtools time-travel, plugins, actions, and cross-route persistence.

43
SeniorCode#System Design#Vue & Nuxt

Vue 3 Error Handling Architecture: `onErrorCaptured` vs `app.config.errorHandler`.

onErrorCaptured: Component-level hook that intercepts errors bubbling up from descendant components • app.config.errorHandler: Global catch-all handler for reporting unhandled errors to observability systems (Sentry, Datadog).

44
SeniorCode#Components#Async & Promises

Dynamic and Async Components in Vue 3: `<component :is="...">` and `defineAsyncComponent`.

Dynamic Components (``): Dynamically swaps active components based on reactive state or tabs • Async Components (defineAsyncComponent): Splits large components into separate lazy bundles loaded on demand, with built-in loading and error.

45
SeniorCode#Memory Management#System Design

Vue 3 `<Teleport>`: Escaping Stacking Contexts for Modals and Popovers.

Teleport renders a component's template DOM node into a different part of the document body (e.g. to="body" or to="#modal-target") while preserving Vue component reactivity, props, and emit hierarchies.

46
SeniorCode#Hooks#System Design

Vue 3 `<Transition>` and `<TransitionGroup>`: Classes, Hooks, and FLIP Animations.

Transition: Applies CSS enter/leave transition classes (v-enter-from, v-enter-active, v-enter-to, v-leave-from, v-leave-active, v-leave-to) to • TransitionGroup: Animates lists of items when elements are inserted, removed, or reordered using FLIP (First, Last, Invert, Play) algorithms.

47
Most AskedSenior#Closures & Scope#System Design

Vue 3 Compiler Internals: Block Trees, Patch Flags, Static Hoisting, and Cache Handlers.

Vue 3's compiler optimizes virtual DOM reconciliation through ahead-of-time (AOT) template analysis: Patch Flags: Numbers embedded in VNodes telling the runtime exactly what needs updating (e.g. 1 for text, 2 for class, 8 for dynamic props).

48
SeniorCode#Components#System Design

Vue 3 Render Functions & JSX: When to Drop Down from Templates.

Render functions use the h() function to programmatically create Virtual DOM nodes (VNodes). While templates are declarative and optimized, render functions provide full JavaScript flexibility for highly dynamic scenarios (e.g. dynamic heading tags h(props.tag, slots.default()) or building form schema...

49
SeniorCode#State Management#System Design

State Persistence and Plugins in Pinia.

Pinia plugins extend stores with cross-cutting concerns like persistence, logging, and error tracking. The $subscribe API listens for mutations and saves state to localStorage or sessionStorage.

50
Senior#Performance#Memory Management

Vue 3 Memory Leaks: Common Pitfalls and Profiling Techniques.

Vue 3 automates most memory management, but common developer oversights cause detached DOM trees and memory bloat: Uncleaned Window / Document Listeners: Adding window.addEventListener('resize', fn) without removing it in onUnmounted • Lingering Timers: setInterval continuing to run after component teardown.