# Vue 3 Script Setup and defineModel in 2026: Modern Syntax and Interview Questions > Master Vue 3 script setup syntax and defineModel for two-way binding. Learn reactive props destructure, TypeScript patterns, and prepare for Vue interview questions. - Published: 2026-09-18 - Updated: 2026-09-18 - Author: Anthony Fillion-Maillet - Tags: vue, vue3, script-setup, definemodel, composition-api, typescript - Reading time: 9 min --- Vue 3 script setup syntax transforms how components are written by eliminating boilerplate and improving TypeScript integration. Combined with `defineModel`, introduced in Vue 3.3 as experimental and stabilized in Vue 3.4, building components with two-way data binding requires far less code than the Options API equivalent. > **Vue 3.5 Reactive Props Destructure** > > Starting in Vue 3.5, props can be destructured directly from `defineProps` while preserving reactivity. This eliminates the need for `toRefs` in most cases. ## Script Setup Fundamentals in Vue 3.5 The ` ``` The compiler handles export statements and component registration automatically. This reduces the cognitive load compared to explicitly returning values from a `setup()` function. ## Reactive Props Destructure (Vue 3.5+) Before Vue 3.5, destructuring props broke reactivity because JavaScript destructuring creates a snapshot of the value at that moment. Vue 3.5 introduces compiler-level tracking that preserves reactivity for destructured props. ```vue ``` This syntax requires Vue 3.5 or later. The [Vue 3.5 release announcement](https://blog.vuejs.org/posts/vue-3-5) documents the complete list of reactive props destructure behavior. ## defineModel for Two-Way Binding Before `defineModel`, implementing `v-model` on a custom component required declaring a prop and emitting an update event manually. This pattern appears in countless Vue codebases: ```vue ``` With `defineModel`, the same component becomes significantly shorter: ```vue ``` The parent component uses standard `v-model` syntax: ```vue ``` `defineModel` returns a ref that stays synchronized with the parent's bound value. Mutations to this ref automatically emit the update event. ## Named Models and Multiple v-model Bindings Components sometimes need multiple two-way bindings. Vue supports named `v-model` bindings, and `defineModel` handles them by accepting a name argument. ```vue ``` The parent binds both models: ```vue ``` ## v-model Modifiers with defineModel Vue's built-in modifiers like `.trim`, `.number`, and `.lazy` work automatically with `defineModel`. Custom modifiers require explicit handling through the second element of the returned tuple. ```vue ``` Usage with the custom modifier: ```vue ``` ## TypeScript Patterns for Script Setup Type safety in ` ``` Generic components, available since Vue 3.3, enable reusable typed components without sacrificing type inference in the consuming code. For deeper patterns, the [Vue documentation on TypeScript](https://vuejs.org/guide/typescript/composition-api.html) covers edge cases. ## Common Interview Questions on Script Setup Interviewers testing Vue knowledge often focus on the differences between script setup and the Options API, as well as the mechanics of reactivity. **Question: Why does destructuring props break reactivity, and how does Vue 3.5 solve this?** In JavaScript, destructuring creates new variables holding the values at destructure time. If `props.count` changes later, a destructured `const { count } = props` still holds the old value. Vue 3.5's compiler transforms the destructured variables into getters that re-evaluate when accessed, preserving reactivity without runtime overhead. **Question: What happens under the hood when defineModel is used?** The compiler expands `defineModel` into a prop declaration and an emit registration. At runtime, it creates a ref whose getter reads the prop value and whose setter calls `emit('update:modelValue', newValue)`. This ref is not a true copy of the prop but a proxy that forwards reads and writes appropriately. **Question: When should a component use script setup versus a regular setup function?** Script setup is preferred for most single-file components because it reduces boilerplate and improves IDE support. A regular `setup()` function is necessary when the component needs to expose methods to parent components via `defineExpose` in complex patterns, or when building renderless components that return render functions directly. For interview preparation, explore more [Vue composables patterns](/technologies/vue-nuxt/interview-questions/vue-composables). ## Migrating from Options API to Script Setup Existing codebases often contain Options API components that benefit from migration. The conversion follows a predictable pattern: ```vue ``` ```vue ``` The migrated version is shorter and type inference works without `PropType` casts. The Vue team provides [vue-codemod](https://github.com/vuejs/vue-codemod) for automated migrations, though manual review remains necessary for complex components. ## Performance Considerations in Script Setup Script setup components compile to more efficient code because the compiler knows the exact shape of the component at build time. Specifically: - Template bindings resolve at compile time rather than runtime property lookup - Unused imports are tree-shaken more effectively - The lack of a wrapping function reduces closure overhead For applications prioritizing bundle size, script setup with [Vapor Mode](https://blog.sparkles-editor.com/en/blog/vue-3-6-rc-upgrade-guide) (available in Vue 3.6+) eliminates the virtual DOM entirely for opted-in components, generating direct DOM operations instead. ## Key Takeaways for Vue 3 Script Setup and defineModel - Script setup reduces component boilerplate by automatically exposing top-level bindings to templates and handling component registration - `defineModel` replaces the manual prop + emit pattern for `v-model`, returning a ref that syncs with the parent's bound value - Vue 3.5 introduces reactive props destructure, allowing `const { prop } = defineProps()` without losing reactivity - Named models support multiple `v-model` bindings on a single component using `defineModel('name')` - TypeScript generics work with `defineProps`, `defineEmits`, `defineSlots`, and generic components via the `generic` attribute - Migration from Options API follows a mechanical pattern: data becomes refs, computed stays computed, methods become functions, and the compiler handles exports --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/en/blog/vue-nuxt/vue-3-script-setup-definemodel-2026