Top 30 Vue.js Interview Questions and Answers [2026]
October 14, 2026
13 min read
TL;DR: Vue.js interviews in 2026 test the Composition API and <script setup>, the Proxy-based reactivity model, Pinia for shared state and SSR with Nuxt. The stable release is Vue 3.5.43 (September 17, 2026); Vue 3.6 and its opt-in Vapor Mode are in release candidate.
Vue 3.5 cut the reactivity system's memory use by 56% with no behavior changes, and Vue 3.6, in release candidate since July 2026, adds a Vapor Mode that compiles components without a virtual DOM.
Around the core, Pinia reached 4.0, Vue Router 5 absorbed file-based routing and Nuxt 4 moved app code into app/. A candidate whose Vue knowledge stops at Vue 2, which reached end of life on December 31, 2023, and Vuex is two eras behind.
Key takeaways
1Destructured props are reactive by default since Vue 3.5, which replaces most uses of withDefaults.
2During server rendering only setup and onServerPrefetch run; onMounted and the other lifecycle hooks do not. We confirmed it with Vue's own server renderer.
3<Suspense> is still marked experimental in the Vue docs, so libraries that depend on it carry API risk.
4Vite 8, released on March 12, 2026, replaced esbuild and Rollup with one Rust bundler, Rolldown.
Reactivity
How the samples were checked. Every code sample on this page ran in a Vitest suite with Vue Test Utils on Vue 3.5.43 and Pinia 4.0.3, and the results quoted in the answers come from those runs.
1. What is the difference between ref and reactive?
ref wraps any value, including primitives, in an object with a .value property; reactive makes an object itself reactive through a Proxy and works only on objects. Templates unwrap refs, so .value appears only in script.
const count = ref(0);
count.value++; // .value in script; templates unwrap it
const form = reactive({ email: "", agreed: false });
form.email = "ada@example.com"; // no .value
const { email } = form; // plain string now: reactivity lost
const { agreed } = toRefs(form); // agreed.value stays linked to form
The trap is destructuring: pulling a property out of a reactive object copies its current value and breaks the link, which the test confirms. toRefs keeps it.
The Vue docs recommend ref as the primary API for exactly this reason, and a candidate who defaults to ref and can explain why is on current guidance.
reactive()
Objects, arrays, Maps and Sets only
Destructuring or reassigning the variable loses reactivity
No .value
ref()
Any value, including strings and numbers
Can be passed to functions and returned without losing reactivity
.value in script, unwrapped in templates
2. When do you use computed instead of a method or a watcher?
Use computed for any value derived from other state. It caches its result and only recomputes when a dependency changes; a method runs on every render.
In our test, reading total three times ran the getter once; pushing an item ran it once more.
A watcher that copies a derived value into another ref is the anti-pattern to watch for: it adds a render cycle where the value is stale and a place for the two to drift apart. Computed getters should also have no side effects.
3. How do you cancel a stale request inside a watcher?
Register cleanup with onWatcherCleanup, added in Vue 3.5. Vue calls it before the watcher runs again and when the watcher stops, so the previous request is aborted.
Typing "a", "ab", "abc" fires three requests; in our test the first two were aborted and only the last one could write results.
Without cleanup, a slow early response can arrive last and overwrite newer results, a race that only shows up on slow networks.
Before 3.5, the same thing needed the onCleanup argument passed to the callback, which still works. watch is lazy and gives old and new values; watchEffect runs immediately and tracks whatever it reads, as question 12 uses.
4. What does nextTick do, and when do you need it?
Vue batches state changes and updates the DOM once, asynchronously. await nextTick() waits for that update to finish, which you need when code reads the DOM right after changing state, for example to measure an element or scroll to a new list item.
Several changes in the same tick produce one render, not several. A candidate who sprinkles nextTick to make things "work" usually has a data-flow problem; one who uses it exactly where the DOM is read has understood the batching.
5. When would you use shallowRef?
For large data that you replace rather than mutate, such as a 10,000-row API response or an object from a charting library. shallowRef tracks only .value, so Vue does not create a Proxy for every nested object.
const rows = shallowRef([]); // only .value itself is tracked
rows.value.push({ id: 1 }); // mutation: no update is triggered
rows.value = [...rows.value, { id: 2 }]; // new array: update is triggered
The cost is that in-place mutations are invisible: our test effect ran once for the mutation line (it did not rerun) and again for the reassignment. markRaw is the tool for objects that must never be made reactive at all, such as a map instance.
6. How does Vue 3's reactivity differ from Vue 2's?
Vue 2 converted each property with Object.defineProperty, so it could not detect added properties or array index assignment and needed Vue.set. Vue 3 wraps objects in Proxies, which see every property read, write, addition and deletion.
const raw = { tags: [] };
const state = reactive(raw);
state === raw; // false: state is a Proxy around raw
toRaw(state) === raw; // true
isReactive(state.tags); // true: nested objects are proxied on access
The side effect interviewers probe: the Proxy is a different object from the original. Code that compares identity, or a library that mutates the raw object, bypasses tracking. toRaw gets the original back when a library needs it.
Components
7. How do props and events work in <script setup>?
Data flows down through props declared with defineProps; the child reports changes up through events declared with defineEmits. Since Vue 3.5, destructured props stay reactive, and JavaScript default values replace withDefaults.
<script setup>
import { watch } from "vue";
const { name, count = 0 } = defineProps({ name: String, count: Number });
const emit = defineEmits(["greet"]);
watch(() => count, (n) => console.log("count is now", n)); // getter needed
</script>
<template>
<p>Hello {{ name }}, you have {{ count }} messages</p>
<button @click="emit('greet', name)">Wave</button>
</template>
Two details decide the answer's quality. A destructured prop is compiled to props.count, so passing it to watch or a composable needs a getter, () => count; passing count directly is a compile-time error.
And a child never assigns to a prop: it emits, and the parent owns the state. Our test set count to 3 and saw both the re-render and the watcher fire.
8. How do you make a component work with v-model?
With defineModel(), stable since Vue 3.4. It returns a ref that reads the modelValue prop and emits update:modelValue when assigned.
The parent writes <QtyInput v-model="qty" />. Clicking plus emitted update:modelValue with 3 in our test. Named models, defineModel("title"), allow several v-models on one component.
The pre-3.4 answer, a prop plus an emit plus a computed with a getter and setter, is still correct, just verbose; see the component v-model guide.
9. What are scoped slots, and when do you need one?
A scoped slot passes data from the child back into the parent's slot content. It is how a list or table component lets the caller decide how each row looks while the component keeps control of the loop, sorting or pagination.
A descendant calls inject(ThemeKey). Providing readonly(theme) plus a toggle function keeps changes going through the provider, and a Symbol key avoids name clashes (typed with InjectionKey in TypeScript).
In our test, a nested button showed "dark", was clicked and showed "light".
11. How do you get a reference to a DOM element?
Since Vue 3.5, with useTemplateRef, matched to a ref attribute by a string key. Before 3.5, you declared a ref with the same name as the attribute.
The ref is null until the component mounts, so reading it belongs in onMounted or later. The advantage of the 3.5 API is that the key is decoupled from the variable name, which also works inside composables.
Our test mounted the component and the input had focus.
12. Write a composable that fetches JSON and refetches when the URL changes.
A composable is a function that uses Composition API features and returns reactive state. toValue lets callers pass a plain string, a ref or a getter.
Called as useFetchJson(() => `/api/users/${id.value}`), it refetches when id changes and aborts the previous request; our test switched the id from 1 to 2 and got the second response.
A senior answer mentions what this does not do: caching, deduplication and SSR. In a Nuxt app, useFetch covers those (question 22).
13. Which lifecycle hooks run during server-side rendering?
Only setup itself and onServerPrefetch. onBeforeMount, onMounted, the update hooks and the unmount hooks do not run on the server, because there is no DOM to mount and the render is a one-off.
We rendered a component registering all eight hooks with renderToString, and only those two fired.
The practical rule from the SSR guide: code that touches window or document goes in onMounted, and a timer started in setup leaks on the server because nothing ever unmounts it.
14. Why do you need key in v-for, and can you combine v-for with v-if?
A stable key lets Vue match old and new elements when a list changes, so component state and DOM focus move with the right item. The index is not a stable key for a list that can be reordered or filtered.
On the same element, v-if runs before v-for in Vue 3 (the reverse of Vue 2), so it cannot see the loop variable. Put the v-for on a <template>:
For a list that is filtered often, a computed that returns the filtered array is cleaner still.
15. What do KeepAlive, Teleport and Suspense do?
KeepAlive caches component instances when they are switched out, so a tab keeps its state; include and max limit what is cached.
Teleport renders its content elsewhere in the DOM, such as a modal at the end of body. Vue 3.5 added defer, which lets it target an element rendered later in the same tick.
Suspense shows fallback content while async components or async setup resolve. The docs still label it experimental, so a senior candidate should flag the risk before building a library on it.
16. How do you test a Vue component?
With Vitest and Vue Test Utils: mount the component, interact through the DOM, and assert on rendered text and emitted events rather than internal state.
import { mount } from "@vue/test-utils";
import { test, expect } from "vitest";
import Counter from "../src/Counter.vue";
test("increments and emits the new value", async () => {
const wrapper = mount(Counter);
await wrapper.get("button").trigger("click");
expect(wrapper.text()).toContain("Clicked 1");
expect(wrapper.emitted("change")).toEqual([[1]]);
});
Awaiting trigger waits for the re-render. Testing through the DOM means the test survives a refactor from Options API to Composition API. For stores, @pinia/testing provides createTestingPinia, which stubs actions by default.
State and Routing
17. How do you write a Pinia store, and how do you read it in a component?
The setup-store syntax is a function that uses refs, computeds and functions, like a component's setup, and returns what the store exposes: refs become state, computeds become getters, functions become actions.
In a component, const cart = useCartStore() and then cart.add(product).
Destructuring the store directly breaks reactivity, the same trap as question 1; storeToRefs(cart) gives reactive refs for state and getters, and actions can be destructured from the store as plain functions.
In our test, adding the same product twice produced one line with a count of 2.
18. Pinia or Vuex for a new project?
Pinia. The Vuex README says Pinia is now the official default, that Vuex 3 and 4 are maintained but unlikely to get new features, and recommends Pinia for new projects.
Pinia drops mutations, has one flat store per concern instead of nested modules, and infers TypeScript types without extra declarations. A migration can be gradual, because both can run in the same app.
19. How do navigation guards and lazy-loaded routes work in Vue Router?
A lazy route passes a function, component: () => import("./pages/Admin.vue"), so the page's code becomes a separate chunk loaded on first visit.
A global router.beforeEach guard returns false to cancel, a route location to redirect, or nothing to continue; per-route beforeEnter and in-component guards cover narrower cases.
Two points separate candidates: guards should return values rather than call the old next() callback, and an auth check in a guard is a user-experience feature, not security. The API must still check permissions.
20. A Vue page is slow. What do you check?
Bundle size: lazy-load routes and heavy components with defineAsyncComponent.
Large reactive data:shallowRef or markRaw for big read-mostly objects (question 5).
Long lists: virtualize them; rendering 5,000 rows is slow in any framework.
Unneeded re-renders: pass stable props so children skip updates; v-memo and v-once for hot spots.
The first step is measuring with Vue DevTools and the browser profiler, not guessing. A candidate who opens the profiler before changing code is the one to hire.
SSR and Nuxt
21. What causes hydration mismatches, and how do you fix them?
A mismatch happens when the HTML rendered on the server differs from what the client renders on its first pass: dates and random numbers, reading window or localStorage in setup, or IDs generated with a counter. Vue 3.5 added two tools:
<script setup>
import { useId } from "vue";
const id = useId(); // same value on the server and in the browser
</script>
<template>
<label :for="id">Email</label>
<input :id="id" type="email" />
</template>
useId() returns the same ID on the server and the client; our server render produced a matching for and id. For values that legitimately differ, data-allow-mismatch silences the warning for that element:
<template>
<span data-allow-mismatch="text">{{ new Date().toLocaleString() }}</span>
</template>
For anything browser-only, render it in onMounted or wrap it in Nuxt's <ClientOnly>.
22. In Nuxt, what is the difference between useFetch and $fetch?
$fetch is a plain HTTP call.
Used in a component's setup, it runs once on the server and again in the browser during hydration. useFetch and useAsyncData run on the server and send the result to the client in the page payload, so the browser does not repeat the call.
The data fetching docs say calling $fetch in setup "may cause data to be fetched twice". The rule: useFetch for data a page renders, $fetch in event handlers such as a form submit.
23. How do you pick a rendering mode per route in Nuxt?
With routeRules in nuxt.config.ts.
The rendering docs show one app mixing modes: prerender: true for a marketing page built at deploy time, swr for pages cached and revalidated in the background, isr for CDN-cached pages on platforms that support it, and ssr: false for an admin area that only renders in the browser.
A strong candidate chooses by how often the data changes and who sees it: product pages can be a few minutes stale, a logged-in dashboard cannot be cached at all.
24. What is Vite's role in a Vue project?
Vite is the dev server and build tool that npm create vue@latest and Nuxt use.
In development it serves source files as native ES modules and updates changed components with hot module replacement; for production it bundles and minifies. @vitejs/plugin-vue compiles single-file components.
Candidates still on Vue CLI and webpack have been on a maintenance-mode tool for years; the question is whether they can explain what moved and why.
The Vue 3.5 announcement of September 1, 2024 lists a reactivity refactor that cut memory use by 56% and made some operations on large reactive arrays up to 10x faster, with no breaking changes.
It also stabilized reactive props destructure (question 7) and added useTemplateRef (question 11), useId and data-allow-mismatch (question 21), onWatcherCleanup (question 3), lazy hydration and deferred Teleport.
Most of this page's answers assume 3.5; a candidate should be able to name at least two of these without prompting.
26. What is Vapor Mode?
An opt-in compilation mode in Vue 3.6 that compiles a component straight to DOM operations instead of a virtual DOM render function, to reduce bundle size and improve performance.
The 3.6 RC notes say it reaches the same level of performance as Solid and Svelte 5 in third-party benchmarks.
A component opts in with <script setup vapor>. Only <script setup> and template-only components are supported, not the Options API, and features that depend on VNodes or the component instance proxy are unavailable.
The Vue team recommends it for performance-sensitive pages in existing apps or small new apps. 3.6 also rebuilds @vue/reactivity on alien-signals.
As of September 2026 it is still a release candidate, so "we use it in production" deserves a follow-up question.
27. What changed in Pinia 3 and Pinia 4?
Pinia 3 (February 11, 2025) added no features: it dropped Vue 2 support and removed deprecated APIs such as defineStore({ id }).
Pinia 4 (July 14, 2026) is ESM only, requires @vue/devtools-api to be installed alongside it, and reworks its errors and dev warnings to be easier to act on.
For an app already on Pinia 2 with setup stores, both upgrades are mostly package bumps; the interview point is knowing that Vue 2 apps are stuck on Pinia 2.
28. What is new in Vue Router 5?
Vue Router 5, released on January 29, 2026, merges unplugin-vue-router into the core package. The release notes call it "a boring release" with no breaking changes apart from the IIFE build dropping the devtools API.
The practical effect is typed, file-based routes (a file in pages/ becomes a route) available without a separate plugin, plus experimental data loaders. Code written against Vue Router 4 keeps working.
29. What changed in Nuxt 4?
Nuxt 4, released on July 15, 2025, moved application code into an app/ directory by default, next to server/, shared/ and public/.
It also reworked data fetching for consistency and performance, and split TypeScript projects so app, server and shared code are type-checked in their own contexts.
The team described it as stability-focused, and most Nuxt 3 projects upgrade with the upgrade guide. The current line is Nuxt 4.5.
30. What does Vite 8 change for Vue developers?
Vite 8 replaced its two bundlers, esbuild in development and Rollup for production, with Rolldown, a single Rust-based bundler. The announcement claims builds up to 10 to 30 times faster with full plugin compatibility.
For most Vue apps, the upgrade is a version bump; the development and production builds now go through the same bundler, which removes a class of "works in dev, breaks in build" bugs caused by the two tools behaving differently.
Signs of a Strong Answer
They default to ref, reach for computed before watch, and can say why.
They spot the destructuring trap in reactive objects and Pinia stores without a hint.
They clean up watchers and effects that start requests or timers.
They know which code runs on the server and keep browser-only code in onMounted.
They put shared logic in composables and choose between provide/inject and Pinia by scope.
They can say which features they use from Vue 3.5, and what Vapor Mode would and would not change for their app.
Hiring Vue.js Developers
Second Talent matches companies with pre-vetted Vue.js developers in Asia, screened on the Composition API, Pinia and Nuxt with questions like these. The Vue developer cost guide lists typical rates by country.