Vue 2 to Vue 3
If you're already experienced with Vue 2 but are new to Vue 3, or if you're migrating an existing Vue 2 app to Vue 3, you should first read through the official migration guide.
Vuetify also offers a migration guide to upgrade from Vuetify 2 to Vuetify 3.
If you're new to Vue entirely, check out the rest of Vue docs and pick your learning path.
Coalesce Upgrade Steps
The changes specific to Coalesce when migrating from Vue2 to Vue3 are pretty minimal. Most of your work will be in following the Vue 3 Migration Guide and the Vuetify 3 Migration Guide.
The table below contains the Coalesce-specific changes when migrating to Vue 3. However, the easiest migration path may be to disregard the table below and instead, instantiate the Coalesce Vue template or look at it on GitHub and compare individual files between your project and the template side by side and ingest the changes that you observe.
Location | Old (Vue 2) | New (Vue 3) |
---|---|---|
package.json | json
| json
|
vite.config.ts | ts
| ts
|
main.ts | ts
| ts
|
router.ts | ts
| ts
|
Vitest/Jest tests | If you had a global test setup file performing Vue configuration, you can likely remove it entirely, or at least remove the parts that configure Vue. Vue3 does not operate on global configuration like Vue2 did. | See test-utils.ts and HelloWorld.spec.ts in the template for examples of Vue3 component testing. |
From Class Components to <script setup>
The components in the Coalesce template for Vue 3 have switched from vue-class-component
to Vue Composition API with <script setup>
, the official recommendation for building full Vue 3 applications.
If you're used to writing components in Vue 2 with vue-class-component
and vue-property-decorator
, you can use this table of comparisons as a quick reference of what the equivalent features are using <script setup>
and Vue Composition API. That said, this is not a replacement for learning and understanding the composition API. You should read the Composition API FAQ as well as the Reactivity Fundamentals documentation (make sure to set the API preference in the top left to Composition!).
If you'd like to continue using class components with Vue 3 (e.g. upgrading an existing project where rewriting all components is not feasible), you can try switching to vue-facing-decorator
.
Note
The examples below assume that unplugin-auto-import
is being used (included in the Coalesce Vue3 template), eliminating the need to manually import common Vue Composition API functions.
Feature | Class Component | Script Setup |
---|---|---|
Coalesce | vue
| vue
|
@Prop, @Watch | vue
| vue
|
Reactive data | vue
| vue
|
Computed values | vue
| vue
|
$emit, methods | vue
| vue
|