Migrate a Vue Options API component to the Composition API with script setup
Scanned 9/3/2026
Install to Claude Code
npx -y skills add black141312/ada --skill vue-composition --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Vue Composition?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/black141312-vue-composition)More formats (shields.io, HTML) on the badges page.
---
name: vue-composition
description: Migrate a Vue Options API component to the Composition API with script setup
category: frameworks
---
# Vue Composition
Use when converting a Vue 2/3 Options API component to `<script setup>` with the Composition API, keeping reactivity and lifecycle behavior intact.
1. Replace the Options block with `<script setup>`; declare `defineProps` and `defineEmits` for the component's props and events.
2. Convert each `data()` field to `ref()` (primitives) or `reactive()` (objects); access `.value` for refs in script.
3. Turn `computed` options into `computed(() => ...)` and `watch`/`watchEffect` for the watchers.
4. Move `methods` to plain functions in setup; map lifecycle hooks (`mounted` → `onMounted`, `beforeUnmount` → `onBeforeUnmount`, etc.).
5. Extract reusable logic into composables (`useXxx()` functions returning refs) instead of mixins.
6. Run the app; verify reactivity (template updates), emitted events, and that hooks fire in order.
## Rules
- In the template, refs auto-unwrap — don't write `.value` there; in script you must.
- Destructuring a `reactive` object breaks reactivity; use `toRefs` if you need to spread it.
- `defineProps`/`defineEmits` are compiler macros — don't import them; they only work in `<script setup>`.
- Replace `this.$emit` with the function returned by `defineEmits`, and `this.$refs` with template `ref()`.
- Prefer composables over mixins; keep each composable focused on one concern and return only what's needed.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!