Modified1 year, 7 months ago. I've currently got a library of Vue2 components I've created and use in several projects via a private npm repo.
I'm starting a new project now in Vue3 but I'd like to use the old components if possible. Can I mix versions like that? Also, can components be mixed the opposite way (Vue3 components in Vue2 apps)? 44 gold badges2828 silver badges4545 bronze badges. 4545 bronze badges. Vue2 components can be used with Vue3 and Vue3 components can be used in Vue2.
As long as you use Classic Vue Js class-based API you should have no issues. Even though some of the underlying technology has been rebuilt, the Vue team has worked hard on making that compatible, though I'm sure there will be some edge cases here and there. The problem will be if you use the Composition API in making your components.
The composition API is built for Vue3, and although you can have a similar experience in Vue2 via a plugin, you are likely going to encounter issues.
Furthermore, even if you are not using the Composition API, you may end up using plugins that do rely on it, which may end up not regression testing against Vue2.
- At the time of writing, Vue 3 was still being released as a RC version.
- This may change very soon, there's not guarantee.
- If you're going to use Vue3 the same way as Vue2, there's little benefit to switching.
- If you are going to use the new features (like the Composition API) then you might end up not being 100% compatible.
- By the sounds of it, Vue2 will have another (LTS) release that will address compatibility issues.
The official recommendation is to start new projects with Vue2 still.
1515 gold badges8585 silver badges133133 bronze badges. 133133 bronze badges. Some of you might hear that the third version of Vue is knocking on the door. Vue JS keeps evolving year by year and Vue 3 is going to be its latest.
Vue 3 and Vue 2 go along a similar line, however, there are significant changes in both. The official version of Vue 3 has been released in September 2020.
Currently the APIs, core, structures are stable and you can use it in production environments.
The question that every Vue.js developer is asking himself is, what are the changes the newest version will bring and how will they impact the overall performance and stability? Our JS developers took a deeper look at the Vue 3, and here are their findings:.
Over the past year, the Vue team has been working on the next major version of Vue.js, which has been released in the second half of 2020.
The rewrite gave the opportunity to rethink the code organization with these things in mind. Upgrades to many aspects of the framework have resulted in speed improvements.
Users report that Vue 3 is about 55 percent faster, memory usage is down to 54 percent and updates are up to 133 percent faster.
This is achieved by completely rewriting the DOM implementation using TypeScript. A new approach to component logic helps with maintenance and makes writing big projects significantly easier.
Vue core team describes Composition API as “a set of additive, function-based APIs that allow flexible composition of component logic“. Vue 3 helps with reducing app complexity, through the years Vue team has noticed that many users are also using Vue to build large scale projects - ones that are iterated on and maintained over a long timeframe, by a team of multiple developers.
Instead of being forced to always organize code by options, code can now be organized as functions each dealing with a specific feature.
The APIs also make it more straightforward to extract and reuse logic between components, or even outside components.
It’s also worth noting that full TypeScript support makes large projects maintenance easier than before.
Also, there is a big game-changer, the authors noticed that users were increasingly using Vue and TypeScript together. To support their use cases, they had to author and maintain TypeScript declarations separately from the source code, which used a different type system.
Switching to TypeScript allows to automatically generate the declaration files, alleviating the maintenance burden. Vue 3 does not change absolutely with Vue 2 but when completed rewriting it from Vue 2, some expected upgrades turn into a reality and that makes the application smaller, faster, and more powerful.
Vue 3’s codebase is written in TypeScript.
So far, there used to be three limitations you may have run into when working with Vue 2:. As your components get larger readability gets difficult. The current code reuse patterns all come with drawbacks. Vue 2 has limited TypeScript support out of the box.
The Vue3 Composition API comes with a setup() method.
This method encapsulates most of our component code and handles reactivity, lifecycle hooks, and many more. In short, the Composition API helps better organize our code into more modular features rather than separating based on the type of property (methods, computed, data).
Rewrite that makes Vue.js 3 smaller and faster
New API and it’s organization make Vue 3 easier to understand if you were previously working with React, switching to Vue will be easier. To use Composition API, we should start with the setup() method.