# Vue Component Best Practices These patterns apply to Vue 3+ and modern Nuxt applications. ## Script Setup Syntax ALWAYS use ` // ✅ Correct: No props used in script // ❌ Wrong: Runtime PropType syntax import type { PropType } from 'vue' defineProps({ items: { type: Array as PropType, required: true } }) ``` ### Emits ALWAYS use type-based syntax for `defineEmits` in TypeScript instead of runtime array syntax. ```typescript // ✅ Correct: Type-based emits const emit = defineEmits<{ update: [value: string] close: [] }>() // ❌ Wrong: Runtime array syntax const emit = defineEmits(["update", "close"]) ``` ### Event Handler Typing When emitting events with event objects, use appropriate event types: ```typescript // ✅ Correct: Typed event handlers const emit = defineEmits<{ click: [event: MouseEvent] keypress: [event: KeyboardEvent] input: [event: InputEvent] submit: [event: SubmitEvent] }>() // Usage in template ``` ### v-model USE `defineModel()` for v-model implementations instead of manually defining props and emits. ```typescript // ✅ Correct: Using defineModel const modelValue = defineModel() // ❌ Wrong: Manual prop + emit const props = defineProps<{ modelValue: string }>() const emit = defineEmits<{ "update:modelValue": [value: string] }>() ``` ## Component Structure ### Template Placement ALWAYS place the `