Skip to main content

Vue 3 Composition API Migration Guide

Migrate a Vue 2 Options API project to Vue 3 Composition API with composables, script setup, and TypeScript integration.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt produces a migration guide for moving a [project_size] Vue 2 project from the Options API to Vue 3 Composition API with <script setup>. It starts from your [current_state] and lays out a migration priority order — shared and base components first — then walks through converting data, computed, methods, and watch into ref, computed, functions, and watch.

The structure works because it sequences the migration so the app stays releasable the whole way through. It extracts reusable logic from [composable_candidates] into composables, migrates Vuex to [state_management], converts mixins to composables with before/after examples, and handles the breaking changes (v-model, emits, filters removal, teleport). A per-component checklist plus effort estimates for [component_count] components turns a daunting rewrite into a steady, component-by-component path.

The guide also covers the parts of a Vue 2 app that are easy to forget. It updates router guards and navigation for Vue Router 4, replaces the old event bus with provide/inject or a small emitter like mitt, and migrates tests to Composition API patterns so coverage does not rot during the move. Starting from your real [current_state] keeps the advice specific — whether you already have TypeScript or Vue Router 4 changes which steps actually apply to you.

When to use it

  • You are modernizing a Vue 2 Options API codebase and want to avoid a risky big-bang rewrite.
  • You need a migration order so shared components move first and nothing breaks mid-flight.
  • You want to extract repeated logic from [composable_candidates] into reusable composables.
  • You are moving from Vuex to [state_management] as part of the upgrade.
  • You need to convert mixins to composables and understand the before/after shape.
  • You want effort estimates for [component_count] components to plan the work.

Example output

Expect a structured migration plan: a prioritized component order, conversion patterns from Options API to <script setup> with code samples, composable extractions for [composable_candidates], the Vuex-to-[state_management] migration, mixin-to-composable before/after examples, a breaking-changes checklist, and a per-component migration checklist with effort estimates. It reads as a playbook you work through rather than a one-shot dump.

Pro tips

  • Be honest in [current_state]; whether you already have TypeScript or Vue Router 4 changes the guidance significantly.
  • Migrate shared and base components first as the order suggests, so downstream components inherit a stable foundation.
  • Pull genuinely repeated logic into composables — chasing the [composable_candidates] that appear in many components gives the biggest payoff.
  • Do the Vuex-to-[state_management] move deliberately; mixing both stores mid-migration is where bugs creep in.
  • Use the per-component checklist to keep the app releasable, shipping migrated components incrementally rather than all at once.
  • Treat the effort estimates for [component_count] as planning guidance, then recalibrate after the first few real migrations.
  • Replace the global event bus deliberately; lingering bus usage is a common source of subtle bugs after the upgrade.
  • Update tests alongside each component so coverage tracks the new Composition API patterns instead of decaying mid-migration.

Frequently Asked Questions

Do I have to migrate the whole project at once?
No, and that is the point of the priority-order approach. Vue 2 and Vue 3 Composition API patterns coexist during migration, so you move component by component starting with shared ones. This keeps the app releasable throughout instead of forcing a risky all-at-once rewrite.
What happens to my Vuex store?
The guide covers migrating Vuex to `[state_management]`, Pinia by default. It is treated as a deliberate step rather than an afterthought, since running both stores during the transition is where subtle state bugs tend to appear, so the plan sequences it carefully.
How are mixins handled?
Mixins are converted to composables, with before-and-after examples showing the transformation. Composables replace mixins cleanly in Vue 3 because they avoid the implicit property-merging and naming collisions that make mixins hard to reason about in larger Options API codebases.
Does the guide cover TypeScript?
Yes, TypeScript integration with proper component typing is included. If your `[current_state]` is plain JavaScript, the migration to `<script setup>` is a natural point to add typing, and the guide addresses component typing as part of the conversion work.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Vue.js & Angular Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support