Migrating to Vue 3

Rate this content
Bookmark

Migrating your Vue 2 app over to Vue 3 doesn't have to be painful. This talk walks you through the process.

This talk has been presented at Vue.js London Live 2021, check out the latest edition of this JavaScript Conference.

FAQ

The Vue 3 migration build is a special version of Vue 3 designed to help developers transition their applications from Vue 2. It operates in a Vue 2 mode, providing warnings about deprecated features and supporting incremental code updates to ensure a smoother upgrade process.

You can access the sample application for Vue 3 migration by cloning the repository link provided in the demonstration or tutorial. This repo includes the necessary setup and examples to help you understand the migration process.

The Vue 3 migration process involves four main steps: 1. Install the migration build, 2. Fix any errors encountered, 3. Address and resolve any warnings, and 4. Uninstall the migration build and update the project dependencies for Vue 3.

For upgrading a Vue CLI-generated app to Vue 3, you can refer to the README on the migration build's GitHub page. It contains detailed instructions and additional resources for different build systems like Vite.

If you encounter errors or warnings after installing the Vue 3 migration build, follow the guided steps to fix these issues. This includes modifying or removing deprecated properties and methods as indicated, and adjusting your code as necessary to comply with Vue 3 standards.

To resolve warnings related to 'global mount' and the 'render function' in Vue 3, you should import and utilize the 'create app' function from Vue 3 to properly initialize your application. This aligns with Vue 3's updated application mounting and rendering methods.

A cheat sheet for migrating from Vue 2 to Vue 3 can be downloaded from vmastery.com. This resource provides a comprehensive list of incompatible features, along with guidance on replaced, removed, or renamed features in Vue 3.

Adam Jahr
Adam Jahr
5 min
21 Oct, 2021

Comments

Sign in or register to post your comment.
Video Summary and Transcription
This talk focuses on the migration process of upgrading Vue CLI-generated apps to Vue 3. It provides step-by-step instructions on removing Vue 2, fixing errors and warnings, and uninstalling the migration build. The talk also mentions a Vue 2 to Vue 3 cheat sheet available for a comprehensive guide. Additionally, the talk introduces a special view three migration build for running existing apps in view two mode, providing warnings and a safe environment for code updates.
Available in Español: Migrando a Vue 3

1. Introduction to React and the Migration Build

Short description:

Welcome back to the talk on working with APIs rewritten for React. We've built a special view three migration build that allows running existing apps in view two mode. It provides warnings about deprecated features and a safe environment for code updates. We'll use a sample app to demonstrate the migration process. Let's install it.

So, welcome back. And welcome back to the talk, which is called what? What applications can you run on React? You can't run a runtime on React. And we're here today to talk about working with APIs that have been rewritten for you to make your Web apps fit in and for your programming experience.

And before we get started, let's take a look at some of the features that we've built and made available for you to use within React. So, here's a couple of the features we've built in our demo. The first one essentially is the view three migration build. Essentially, it's a special version of view three that allows you to run your existing app in view two mode. It gives you helpful warnings about deprecated features and provides a safe environment to incrementally update your code.

In order to get some practice and see what it looks like to use the migration build, we're going to use a simple sample application. You can access the repo by cloning this link here, and we can see how we made those changes to upgrade it into view three with the help of the migration build.

Before we get started, let's take a look at that sample app in the browser. As you can see, it's very simple. You just hit that pop button and it pops off the number from the bottom of that list. To make this migration process more realistic, we built in some deprecated features into this demo app, which we're going to have to upgrade to make it view three compliant. Now that we've seen the app that we're upgrading, what does the four-step process? You install it, fix the errors, fix the warnings, then uninstall it. So let's go ahead and install it.

2. Upgrading Vue CLI-Generated App to Vue 3

Short description:

To upgrade a Vue CLI-generated app to Vue 3, run VueUpgrade in the terminal. Remove Vue 2 and the Vue template compiler, install dependencies, and create a vue.config file. Fix errors by removing the functional attribute and props. Fix warnings by importing create app and adding the deep option. Uninstall the migration build and delete the config file. Download the Vue 2 to Vue 3 cheat sheet at vmastery.com for a comprehensive guide.

Since a lot of people use the Vue CLI to create their Vue2 apps, I'm going to be showing how to upgrade a Vue CLI-generated app. If you're using Vite or some other build system, you can check out the README on the migration build's GitHub. But moving forward with the Vue CLI, we're going to want to make sure that we have the newest version of it installed. So we'll want to run VueUpgrade in our terminal.

We'll need to use JSON to install Vue 3, the migration build itself, and the compiler for single-file components. Notice how we also have to remove Vue 2 and the Vue template compiler. Next we can install the dependencies, and there's one more step to get the migration build working. We have to create a vue.config file to set up some compiler options. You can find this config file in the Ending branch of our demo code, and also I want to let you know we have a full blog series about this migration build. You can find any of this content, any of this code, you can find at vuemastery.com slash blog.

With that out of the way, we can now serve our app, but you'll see we're met with an error. This is actually a good sign. It's proving that the migration build is doing its job and letting us know that there is something wrong with our code, something deprecated. This brings us to the next step in our migration build workflow, where we fix the errors. The source of this error is from our sample app's default API. To fix that and make this Vue 3 compliant, we're going to delete out the functional attribute and remove the props. as well. Now the error should be gone. But you might notice that we still have some warnings in the console. One is about global mount, another is about the render function, and another is about the watch array. So let's move on to our third step where we fix those warnings. We can knock out two of those warnings by importing and using create app to initialize our app. Now if you refresh the app in the browser, you'll see a new warning. To fix this final issue, we just need to add the deep option here as instructed by the warning. Now that we've fixed our errors and warnings, we can move on to the final step where we uninstall the migration build from the package JSON and delete out the config file. Now we can go ahead and run npm install and serve our newly upgraded Vue 3 app.

Of course, the demo app that we just walked through was pretty simple. It just had a handful of errors and warnings and was pretty quick to fix. In your case, in the real world, you're going to see a lot of different situations, errors, warnings, and deprecations that are unique to your use case. So to make it easier for you to upgrade your own apps, we created a cheat sheet to list out all the Vue 2 features that are incompatible with Vue 3 that are going to give you those errors. And it guides you through all those features that were replaced, removed, and renamed in Vue 3. You can download the cheat sheet free at vmastery.com. So with all that, I hope you feel more confident and prepared to upgrade your Vue 2 apps to Vue 3.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Everything Beyond State Management in Stores with Pinia
Vue.js London Live 2021Vue.js London Live 2021
34 min
Everything Beyond State Management in Stores with Pinia
Top Content
State management is not limited to complex applications and transitioning to a store offers significant benefits. Pinia is a centralized state management solution compatible with Vue 2 and Vue 3, providing advanced devtools support and extensibility with plugins. The core API of Pinia is similar to Vuex, but with a less verbose version of stores and powerful plugins. Pinia allows for easy state inspection, error handling, and testing. It is recommended to create one file per store for better organization and Pinia offers a more efficient performance compared to V-rex.
Welcome to Nuxt 3
Vue.js London Live 2021Vue.js London Live 2021
29 min
Welcome to Nuxt 3
Top Content
Nux3 has made significant improvements in performance, output optimization, and serverless support. Nuxt Bridge brings the Nitro engine for enhanced performance and easier transition between Nuxt 2 and Nuxt Read. Nuxt 3 supports Webpack 5, Bytes, and Vue 3. NextLab has developed brand new websites using Docus technology. Nuxt.js is recommended for building apps faster and simpler, and Nuxt 2 should be used before migrating to Nuxt 3 for stability. DOCUS is a new project that combines Nuxt with additional features like content modules and an admin panel.
One Year Into Vue 3
Vue.js London Live 2021Vue.js London Live 2021
20 min
One Year Into Vue 3
Top Content
Vue 3 has seen significant adoption and improvements in performance, bundle size, architecture, and TypeScript integration. The ecosystem around Vue 3 is catching up, with new tools and frameworks being developed. The Vue.js.org documentation is undergoing a complete overhaul. PNIA is emerging as the go-to state management solution for Vue 3. The options API and composition API are both viable options in Vue 3, with the choice depending on factors such as complexity and familiarity with TypeScript. Vue 3 continues to support CDN installation and is recommended for new projects.
Utilising Rust from Vue with WebAssembly
Vue.js London Live 2021Vue.js London Live 2021
8 min
Utilising Rust from Vue with WebAssembly
Top Content
In this Talk, the speaker demonstrates how to use Rust with WebAssembly in a Vue.js project. They explain that WebAssembly is a binary format that allows for high-performance code and less memory usage in the browser. The speaker shows how to build a Rust example using the WasmPack tool and integrate it into a Vue template. They also demonstrate how to call Rust code from a Vue component and deploy the resulting package to npm for easy sharing and consumption.
Vue: Feature Updates
Vue.js London 2023Vue.js London 2023
44 min
Vue: Feature Updates
Top Content
Watch video: Vue: Feature Updates
The Talk discusses the recent feature updates in Vue 3.3, focusing on script setup and TypeScript support. It covers improvements in defining props using imported types and complex types support. The introduction of generic components and reworked signatures for defined components provides more flexibility and better type support. Other features include automatic inference of runtime props, improved define emits and defined slots, and experimental features like reactive props destructure and define model. The Talk also mentions future plans for Vue, including stabilizing suspense and enhancing computer invalidations.
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
This Talk discusses handling local state in software development, particularly when dealing with asynchronous behavior and API requests. It explores the challenges of managing global state and the need for actions when handling server data. The Talk also highlights the issue of fetching data not in Vuex and the challenges of keeping data up-to-date in Vuex. It mentions alternative tools like Apollo Client and React Query for handling local state. The Talk concludes with a discussion on GitLab going public and the celebration that followed.

Workshops on related topic

Vue3: Modern Frontend App Development
Vue.js London Live 2021Vue.js London Live 2021
169 min
Vue3: Modern Frontend App Development
Top Content
Featured WorkshopFree
Mikhail Kuznetsov
Mikhail Kuznetsov
The Vue3 has been released in mid-2020. Besides many improvements and optimizations, the main feature of Vue3 brings is the Composition API – a new way to write and reuse reactive code. Let's learn more about how to use Composition API efficiently.

Besides core Vue3 features we'll explain examples of how to use popular libraries with Vue3.

Table of contents:
- Introduction to Vue3
- Composition API
- Core libraries
- Vue3 ecosystem

Prerequisites:
IDE of choice (Inellij or VSC) installed
Nodejs + NPM
Monitoring 101 for React Developers
React Summit US 2023React Summit US 2023
107 min
Monitoring 101 for React Developers
Top Content
WorkshopFree
Lazar Nikolov
Sarah Guthals
2 authors
If finding errors in your frontend project is like searching for a needle in a code haystack, then Sentry error monitoring can be your metal detector. Learn the basics of error monitoring with Sentry. Whether you are running a React, Angular, Vue, or just “vanilla” JavaScript, see how Sentry can help you find the who, what, when and where behind errors in your frontend project. 
Workshop level: Intermediate
Using Nitro – Building an App with the Latest Nuxt Rendering Engine
Vue.js London Live 2021Vue.js London Live 2021
117 min
Using Nitro – Building an App with the Latest Nuxt Rendering Engine
Top Content
Workshop
Daniel Roe
Daniel Roe
We'll build a Nuxt project together from scratch using Nitro, the new Nuxt rendering engine, and Nuxt Bridge. We'll explore some of the ways that you can use and deploy Nitro, whilst building a application together with some of the real-world constraints you'd face when deploying an app for your enterprise. Along the way, fire your questions at me and I'll do my best to answer them.
Going on an adventure with Nuxt 3, Motion UI and Azure
JSNation 2022JSNation 2022
141 min
Going on an adventure with Nuxt 3, Motion UI and Azure
WorkshopFree
Melanie de Leeuw
Melanie de Leeuw
We love easily created and deployed web applications! So, let’s see what a very current tech stack like Nuxt 3, Motion UI and Azure Static Web Apps can do for us. It could very well be a golden trio in modern day web development. Or it could be a fire pit of bugs and errors. Either way it will be a learning adventure for us all. Nuxt 3 has been released just a few months ago, and we cannot wait any longer to explore its new features like its acceptance of Vue 3 and the Nitro Engine. We add a bit of pizzazz to our application with the Sass library Motion UI, because static design is out, and animations are in again.Our driving power of the stack will be Azure. Azure static web apps are new, close to production and a nifty and quick way for developers to deploy their websites. So of course, we must try this out.With some sprinkled Azure Functions on top, we will explore what web development in 2022 can do.
TresJS create 3D experiences declaratively with Vue Components
Vue.js London 2023Vue.js London 2023
137 min
TresJS create 3D experiences declaratively with Vue Components
Workshop
Alvaro Saburido
Alvaro Saburido
- Intro 3D - Intro WebGL- ThreeJS- Why TresJS- Installation or Stackblitz setup - Core Basics- Setting up the Canvas- Scene- Camera- Adding an object- Geometries- Arguments- Props- Slots- The Loop- UseRenderLoop composable- Before and After rendering callbacks- Basic Animations- Materials- Basic Material- Normal Material- Toon Material- Lambert Material- Standard and Physical Material- Metalness, roughness - Lights- AmbientLight- DirectionalLight- PointLights- Shadows- Textures- Loading textures with useTextures- Tips and tricks- Misc- Orbit Controls- Loading models with Cientos- Debugging your scene- Performance
Building Vue forms with VeeValidate
Vue.js London Live 2021Vue.js London Live 2021
176 min
Building Vue forms with VeeValidate
Workshop
Abdelrahman Awad
Abdelrahman Awad
In this workshop, you will learn how to use vee-validate to handle form validation, manage form values and handle submissions effectively. We will start from the basics with a simple login form all the way to using the composition API and building repeatable and multistep forms.

Table of contents:
- Introduction to vee-validate
- Building a basic form with vee-validate components
- Handling validation and form submissions
- Building validatable input components with the composition API
- Field Arrays and repeatable inputs
- Building a multistep form
Prerequisites:
VSCode setup and an empty Vite + Vue project.