Let’s take a look at some of the most exciting new features you can take advantage of as a Vue 3 developer.
Vue 2 is quite small, at around 20kb gzipped at runtime. And Vue 3 is just as compact, while bringing new features and improvements. Vue 3 also allows us to only import only the pieces of the library that we need, which means whatever we don’t use will be removed for us via treeshaking. As a result, Vue 3 can be reduced even further to as small as 12kb gzipped.
Since the Virtual DOM has been rewritten from the ground up with a new diffing algorithm that uses compiler-based optimizations, this results in faster rendering times.
One of the biggest features coming in Vue 3 is the Composition API. With Vue 2, sometimes our large components ended up with features dispersed amongst the component’s options, which could make them difficult to manage and maintain. The Composition API provides a new alternative syntax that gives developers a better way to manage features and functionality across components, allowing you to smoothly scale your applications.
Vue 3’s source code is written entirely in TypeScript. As a result, this means enhanced support for TypeScript users, but just like in Vue 2, using TypeScript is optional and not required.
Most front end frameworks require you to wrap a component’s template code in a single element because sibling elements aren’t allowed. But with Vue 3, we can now use multi-root components.
Sometimes a piece of a component’s template belongs there logically, but it would be preferable to render it somewhere else. Vue 3 gives us the Teleport component, which allows us to specify template HTML that we can send to another part of the DOM.
This is useful for things like modals, which may need to be placed outside of the
body tag or outside the Vue app.
But wait, there’s more…
These are just a handful of ways Vue 3 empowers you and your team to build better Vue apps. With so many new features to learn, you’ll want to check out the official Vue 3 docs, and I invite you to explore our collection of Vue 3 courses here on Vue Mastery, including a Deep Dive into Vue 3 with the creator of Vue, Evan You.