Vue
Based on Vue 3.5. Always use Composition API with <script setup lang="ts">.
Preferences
- Prefer TypeScript over JavaScript
- Prefer
<script setup lang="ts"> over <script>
- For performance, prefer
shallowRef over ref if deep reactivity is not needed
- Always use Composition API over Options API
- Discourage using Reactive Props Destructure
Core
| Topic |
Description |
Reference |
| Script Setup & Macros |
<script setup>, defineProps, defineEmits, defineModel, defineExpose, defineOptions, defineSlots, generics |
script-setup-macros |
| Reactivity & Lifecycle |
ref, shallowRef, computed, watch, watchEffect, effectScope, lifecycle hooks, composables |
core-new-apis |
Features
| Topic |
Description |
Reference |
| Built-in Components & Directives |
Transition, Teleport, Suspense, KeepAlive, v-memo, custom directives |
advanced-patterns |
Quick Reference
Component Template
<script setup lang="ts">
import { ref, computed, watch, onMounted } from 'vue';
const props = defineProps<{
title: string;
count?: number;
}>();
const emit = defineEmits<{
update: [value: string];
}>();
const model = defineModel<string>();
const doubled = computed(() => (props.count ?? 0) * 2);
watch(
() => props.title,
newVal => {
console.log('Title changed:', newVal);
},
);
onMounted(() => {
console.log('Component mounted');
});
</script>
<template>
<div>{{ title }} - {{ doubled }}</div>
</template>
Key Imports
// Reactivity
import {
ref,
shallowRef,
computed,
reactive,
readonly,
toRef,
toRefs,
toValue,
} from 'vue';
// Watchers
import { watch, watchEffect, watchPostEffect, onWatcherCleanup } from 'vue';
// Lifecycle
import {
onMounted,
onUpdated,
onUnmounted,
onBeforeMount,
onBeforeUpdate,
onBeforeUnmount,
} from 'vue';
// Utilities
import { nextTick, defineComponent, defineAsyncComponent } from 'vue';
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: vue-273description: 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. Use when this capability is needed.4---56# Vue78> Based on Vue 3.5. Always use Composition API with `<script setup lang="ts">`.910## Preferences1112- Prefer TypeScript over JavaScript13- Prefer `<script setup lang="ts">` over `<script>`14- For performance, prefer `shallowRef` over `ref` if deep reactivity is not needed15- Always use Composition API over Options API16- Discourage using Reactive Props Destructure1718## Core1920| Topic | Description | Reference |21| ---------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |22| Script Setup & Macros | `<script setup>`, defineProps, defineEmits, defineModel, defineExpose, defineOptions, defineSlots, generics | [script-setup-macros](references/script-setup-macros.md) |23| Reactivity & Lifecycle | ref, shallowRef, computed, watch, watchEffect, effectScope, lifecycle hooks, composables | [core-new-apis](references/core-new-apis.md) |2425## Features2627| Topic | Description | Reference |28| -------------------------------- | -------------------------------------------------------------------- | ---------------------------------------------------- |29| Built-in Components & Directives | Transition, Teleport, Suspense, KeepAlive, v-memo, custom directives | [advanced-patterns](references/advanced-patterns.md) |3031## Quick Reference3233### Component Template3435```vue36<script setup lang="ts">37 import { ref, computed, watch, onMounted } from 'vue';3839 const props = defineProps<{40 title: string;41 count?: number;42 }>();4344 const emit = defineEmits<{45 update: [value: string];46 }>();4748 const model = defineModel<string>();4950 const doubled = computed(() => (props.count ?? 0) * 2);5152 watch(53 () => props.title,54 newVal => {55 console.log('Title changed:', newVal);56 },57 );5859 onMounted(() => {60 console.log('Component mounted');61 });62</script>6364<template>65 <div>{{ title }} - {{ doubled }}</div>66</template>67```6869### Key Imports7071```ts72// Reactivity73import {74 ref,75 shallowRef,76 computed,77 reactive,78 readonly,79 toRef,80 toRefs,81 toValue,82} from 'vue';8384// Watchers85import { watch, watchEffect, watchPostEffect, onWatcherCleanup } from 'vue';8687// Lifecycle88import {89 onMounted,90 onUpdated,91 onUnmounted,92 onBeforeMount,93 onBeforeUpdate,94 onBeforeUnmount,95} from 'vue';9697// Utilities98import { nextTick, defineComponent, defineAsyncComponent } from 'vue';99```100101---102> Converted and distributed by [TomeVault](https://tomevault.io/claim/kriollo) — claim your Tome and manage your conversions.103<!-- tomevault:4.0:skill_md:2026-04-16 -->