Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Vue 3 Composition API reference—script setup macros, reactivity, lifecycle hooks, and built-in components
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: vue3description: Vue 3 Composition API, script setup macros, reactivity system, and built-in components. Use when writing Vue SFCs, defineProps/defineEmits/defineModel, watchers, or using Transition/Teleport/Suspense/KeepAlive.4metadata:5author: Anthony Fu6version: "2026.1.31"7source: Generated from https://github.com/vuejs/docs, scripts at https://github.com/antfu/skills8---910# Vue1112> Based on Vue 3.5. Always use Composition API with `<script setup lang="ts">`.1314## Preferences1516- Prefer TypeScript over JavaScript17- Prefer `<script setup lang="ts">` over `<script>`18- For performance, prefer `shallowRef` over `ref` if deep reactivity is not needed19- Always use Composition API over Options API20- Discourage using Reactive Props Destructure2122## Core2324| Topic | Description | Reference |25|-------|-------------|-----------|26| Script Setup & Macros | `<script setup>`, defineProps, defineEmits, defineModel, defineExpose, defineOptions, defineSlots, generics | [script-setup-macros](references/script-setup-macros.md) |27| Reactivity & Lifecycle | ref, shallowRef, computed, watch, watchEffect, effectScope, lifecycle hooks, composables | [core-new-apis](references/core-new-apis.md) |2829## Features3031| Topic | Description | Reference |32|-------|-------------|-----------|33| Built-in Components & Directives | Transition, Teleport, Suspense, KeepAlive, v-memo, custom directives | [advanced-patterns](references/advanced-patterns.md) |3435## Quick Reference3637### Component Template3839```vue40<script setup lang="ts">41import { ref, computed, watch, onMounted } from 'vue'4243const props = defineProps<{44title: string45count?: number46}>()4748const emit = defineEmits<{49update: [value: string]50}>()5152const model = defineModel<string>()5354const doubled = computed(() => (props.count ?? 0) * 2)5556watch(() => props.title, (newVal) => {57console.log('Title changed:', newVal)58})5960onMounted(() => {61console.log('Component mounted')62})63</script>6465<template>66<div>{{ title }} - {{ doubled }}</div>67</template>68```6970### Key Imports7172```ts73// Reactivity74import { ref, shallowRef, computed, reactive, readonly, toRef, toRefs, toValue } from 'vue'7576// Watchers77import { watch, watchEffect, watchPostEffect, onWatcherCleanup } from 'vue'7879// Lifecycle80import { onMounted, onUpdated, onUnmounted, onBeforeMount, onBeforeUpdate, onBeforeUnmount } from 'vue'8182// Utilities83import { nextTick, defineComponent, defineAsyncComponent } from 'vue'84```85