Тёмный

Why You Don't Need The Vue.js 3 Composition API! Composition API vs Options API Vue.js 3 comparision 

Program With Erik
Подписаться 122 тыс.
Просмотров 25 тыс.
50% 1

Let's take a look at the composition API vs Options API vs Script Setup vs Hybrid. Which one is better? Which should you use in Vue.js 3? Let's take a look!
👉Check out my last video on Watch vs WatchEffe4ct
• Vue 3 Watch vs WatchEf...
👉 Sign up and get free Vue cheat sheets and updates!
www.vuecourse.tech/
Need some mentoring, help with a project, get a career in tech, level up your skills? Check it out
👉mentorcruise.com/mentor/erikh...
Need to Learn Vue or Nuxt? Check out my courses below!
bit.ly/2LalQka - Learn Nuxt.js Course!
bit.ly/3aiYe8s - Quick Starter On Vue 3
bit.ly/2OETt0M - Full 6 Module course on vue!
0:00 Introduction
0:40 Options API
03:17 Composition API
05:32 Script Setup
07:02 Hybrid Approach
🗂️ 🗂️ 🗂️
Links

Опубликовано:

 

30 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 76   
@ProgramWithErik
@ProgramWithErik 2 года назад
👉 Sign up and get free Vue cheat sheets and updates! www.vuecourse.tech/
@AkshaySood1
@AkshaySood1 2 года назад
Having worked with both Options API and Composition API, I have fallen in love with Composition API with script setup. Using it with TS, and JS is ❤ again! 😊
@Algebrodadio
@Algebrodadio 2 года назад
Maybe it's because I'm so comfortable with it, but I really like the Vue.js 2 way of doing things. It forces developers to be organized. And yeah, I know that's what turns a lot of devs off of Vue 2. But it's what I like about it.
@Forshen
@Forshen Год назад
same, the OptionsAPI gives you a structure, Composition API can be written like PHP a.k.a garbage. Its up to the developer to keep it clean. That part sucks.
@greggsworld4453
@greggsworld4453 Год назад
I have seen some react components that I literally couldnt make sense of because of this composition api approach. Yes Options api wasnt all that but I too loved the organization to an extent and the easy reactivity, i hate having to do .value on a property to get a value now.
@mcvgs1780
@mcvgs1780 2 года назад
Composition API in my opinion feels clean and natural. I much prefer it compared to Options. In the end it is up to you which one you are more comfortable with.
@TysonLondon
@TysonLondon 2 года назад
I got into vusejs because the options api seemed less complex than react. Now having built a number of applications with react, the composition api in vuejs makes me just want to develop using react.
@u4yk
@u4yk 2 года назад
The only thing I do miss going from the Options API to Composition is inheritance. I miss being able to "classically" extend a component to a child component, and I've never been a fan of composing my extensions. The ability to extend components like that was the main reason I went from React to Vue, and the Composition API in Vue seems like it's trying to follow React's paradigm. Granted, Vue's Composition API is far less hacky than React's Hooks API, but it still feels like Vue is just trying to be more like React for the sake of being more like React. One thing you left out -- Pinia primarily works with the Composition API (specifically the setup() function). It'll work with the Options API, but integration is much simpler with setup(). At least, it was for me. So, if you're planning to use Vuex's replacement or start a Nuxt 3 project, it's likely you're better off going the Composition route.
@Forshen
@Forshen Год назад
I am using pinia with options API, just follow the vue2 docs (while using vue3 in the project) and everything worked fine.
@u4yk
@u4yk Год назад
@@Forshen I didn't say it couldn't be done or that it was difficult, but Pinia is so dead simple to work with if you're using the Composition API.
@simonschroder9855
@simonschroder9855 2 года назад
This was really helpful, since I'm somewhat a beginner with Vue and didn't get the full meaning of the APIs. Maybe you want to do an (even) shorter video stating just the basics and maybe referring to this one. I could imagine people watching it just to get the APIs.
@ShamanS08
@ShamanS08 2 года назад
Could you explain how to build and more importantly test services using composition API? Would you even put business logic in composable "services" in a non trivial prod app?
@Sk8nRock
@Sk8nRock Год назад
Don't know if anybody else pointed this out already, but using the hybrid approach you can actually access the refs and functions returned by the setup method in your options API code just fine by using "this".
@danielmbirch
@danielmbirch Год назад
As someome relatively new to Vue, the options API feels more approachable and intuitive to use. And more organised.
@ProgramWithErik
@ProgramWithErik Год назад
I can see that. Composition API is not for everyone.
@ohidotg
@ohidotg 4 месяца назад
I am the "jack of all trades" guy in our tech. I really don't have time to dive deep. Thus, options API feels more intuitive and pragmatic to me.
@jonathanbereyziat4063
@jonathanbereyziat4063 2 года назад
Nice videos ! Very helpful to refactor my projects :) I’ve seen that you were offering mentoring before is it still a thing ? Cause I would be very interested
@adin00
@adin00 2 года назад
After fiddling for a bit with TS+ESLint with the Options API I came to the conclusion that this particular config is unusable (lots of false positives involving `this` keyword being undefined) I went head on for Composition API and never looked back.
@blank4157
@blank4157 2 года назад
Agreed, had same experience with options API. With composition API, vue's DX have improved significantly and now on par with other popular frameworks.
@ProgramWithErik
@ProgramWithErik 2 года назад
It does take a bit of configuration.
@nontkung1755
@nontkung1755 2 года назад
Thank you. It's very useful for me
@bharathhs1161
@bharathhs1161 Месяц назад
Always options api easy organised and the very reason why i fell in love with vue,
@romanchechel2895
@romanchechel2895 2 года назад
What theme do u use for vscode?
@aymanfadli852
@aymanfadli852 6 месяцев назад
thank you for this awesome video ❤
@QtheCoder
@QtheCoder 2 года назад
Can we get a video on fetching with nuxt 3?
@Sirfrummel
@Sirfrummel 2 года назад
What the heck, how do you get glowing syntax?? That color scheme is awesome
@AdroSlice
@AdroSlice 2 года назад
Composition API: When multiple components need the same ancestor data, or when a deeply nested component needs ancestor data Options API: When a child component needs parent data
@Prestorizzor
@Prestorizzor 2 года назад
Lmao
@ohidotg
@ohidotg 4 месяца назад
Composition API's context: Don't we have statement management for that?
@pieman123456100
@pieman123456100 Год назад
what plugin do you use to get certain keywords to glow in this neon style?
@wladimirllanos1438
@wladimirllanos1438 Год назад
SynthWave '84
@aj.arunkumar
@aj.arunkumar 2 года назад
finally....! thanks for saying this... i was so sick of people saying composition api is going to "replace" options api...
@leonpilot737
@leonpilot737 2 года назад
What about #5 - JSX like approach and #6 - render functions?
@wobsoriano
@wobsoriano 2 года назад
I only use render functions on component libraries
@folkrav
@folkrav 2 года назад
Honestly, just for the TS support the composition API is worth it.
@migmartin
@migmartin 2 года назад
I do not see return object in Setup API #3
@ufdiu3n8s2
@ufdiu3n8s2 2 года назад
Web3 with Vue would be amazing!
@ProgramWithErik
@ProgramWithErik 2 года назад
Cool, I'll be looking into it soon!
@abc33155
@abc33155 2 года назад
This video doesn’t talk about why we don’t need the composition API, it actually recommends it. The title is wrong.
@ProgramWithErik
@ProgramWithErik 2 года назад
Well, I think either one will work, but I really do like the options API>
@samueltesh8068
@samueltesh8068 2 года назад
Too many ways to do the same thing. This will really mess up the ecosystem
@doublemarvellous5525
@doublemarvellous5525 2 года назад
This is what drives me crazy. As soon as you learn something it has become the passe way to do it.
@wildthreshold
@wildthreshold 2 года назад
@@doublemarvellous5525 welcome to the dev jog !! 😅
@Urbaez22
@Urbaez22 2 года назад
I don't think it will, actually I think it has already done it..
@mandlankosi2160
@mandlankosi2160 Год назад
unopinionated frameworks
@svenyboyyt2304
@svenyboyyt2304 Год назад
​@@doublemarvellous5525 You can still use Options API. There was 1 (one) change. Then they made it so that you could remove some boilerplate code. I don't know what you're so annoyed about.
@Shafikulislam-up1rr
@Shafikulislam-up1rr 9 месяцев назад
what is code editor theme name?
@Smoonwalkerm
@Smoonwalkerm 2 года назад
web 3 ? YEAH ABSOLUTELY!!...a solana app would be awesome!
@quentinsavoy4117
@quentinsavoy4117 2 года назад
Options API has always been more readable but YOU MISS ONE BIG ASSET of the composition API imho: you expose only what you need to the template, hence not polluting it with your intermediate computed (since VueJS Guidelines tells us to make as many atomic computed properties as possible). Thoughts?
@quentinsavoy4117
@quentinsavoy4117 2 года назад
Good video still, keep it up!
@OzoneGrif
@OzoneGrif 2 года назад
I really love the script setup syntax: it's verbose, but explicit. All the magic Vue does in background with the Option API is gone. There's only one issue I'm trying to solve, with Volar and the strong typing of components; how to chain $attrs but keep Volar happy with the typings: how to declare that I want to chain a Prop or Event without redeclaring it multiple times.
@SR-cm2my
@SR-cm2my 2 года назад
What works best for me especially when we're a team of ten plus developers is writing class based components. Typescript + Vue-property-decorator + Vue.js 3 has been nothing but a delight for us. The backend developers love to work on the front end too!
@hansadmiraal
@hansadmiraal 2 года назад
We use vue-class-component (on which vue-property-decorator is based). Works great, looks great, but it is not supported by Volar or Vetur, which is a serious disadvantage.
@SR-cm2my
@SR-cm2my 2 года назад
@@hansadmiraal I can see you having issues with Vetur. We've resorted to writing our own snippets and configuring vetur to match class based components. Hope that helps!
@ExpensivePizza
@ExpensivePizza 2 года назад
6:25 t-i-h-i-s 😂
@larscwallin
@larscwallin 2 года назад
Can you still use TypeScript class syntax with Vue 3?
@wobsoriano
@wobsoriano 2 года назад
It should work
@AngelHdzMultimedia
@AngelHdzMultimedia 2 года назад
Yes, but. The mantainer of the vue-class-component package that brings typescript decorators to Vue has not been maintaning it, so much so that Quasar already put a deprecation notice and recommends the Composition API instead. I need to catch up, maybe for non-Quasar pure Vue apps we can still use it. I really love class-based components.
@behnamsalehi9765
@behnamsalehi9765 2 года назад
Options API is organized and I believe that's more important
@scryptum
@scryptum 2 года назад
Web3 web3 web3 !!
@vigilantezack
@vigilantezack 2 года назад
There are 5 ways to run Vue ......... what we need is a new way to rule them all and unify! .................. there are now 6 ways to run Vue ......
@hmatpin
@hmatpin 2 года назад
After React hooks, Vue does not seem better than React. I think Vue didn't need to evolve into V3. V2 was just perfect. They should've just added TS to V2
@blank4157
@blank4157 2 года назад
It's completely impossible to give 100% TS support in options API if you know how mixins work in vue.
@OlmTheHunter
@OlmTheHunter 2 года назад
DOM implementation has been completely rewritten in Vue 3 (using latest JS/TS and browser features), which leads to major performance improvements (55% faster, memory usage is down to 54%, updates up to 133%). Build time and size are also significantly improved.
@samuelmorkbednarzkepler
@samuelmorkbednarzkepler 2 года назад
A: Vue composition API, composables, script setup, css v-bind, full TS support, increased performance and modularity. These are all incredibly good reasons to evolve into V3. Fact is that V2 was not perfect and V3 is a massive improvment. Also, B: Vue composables are way better than React hooks and im tired of pretending they are not
@tanzimibthesam5861
@tanzimibthesam5861 2 года назад
If you still use Redux there is no point of Hooks Vue3 composition Api with composables is lit
@JenuelDev
@JenuelDev 2 года назад
In my experience., if your creating child component and u want to access its functions or variable using ref, dont use script setup,, use setup() function or the options API... for setup() function, u can only access variables/functions that are returned.
@ProgramWithErik
@ProgramWithErik 2 года назад
interesting.
@jonathanbereyziat4063
@jonathanbereyziat4063 2 года назад
With vue 3 and the script setup approach template refs and reactive refs are kinda merged in the same logique so even in the script setup you can actually access in a very clean fashion to the children components and it’s functions or attributes (also don’t forget to use defineExpose to make functions and attributes available in your child components) ^^
@wobsoriano
@wobsoriano 2 года назад
You have to use defineExpose to access properties declared in a script setup.
@AngelHdzMultimedia
@AngelHdzMultimedia 2 года назад
"In my experience" Didn't you know, in your experience, that exposes stand-alone functions to define props, emits, and provide data to child components?
@Neo-qj2zb
@Neo-qj2zb 2 года назад
Options API gets very ugly when you lots of large components, I personally prefer Composition API
@brokula1312
@brokula1312 2 года назад
There are 0 reasons to use OptionsAPI.
@pedrogouveiasousa
@pedrogouveiasousa 2 года назад
Erick, don't put this title, composition API it's the way to go. Errrrr....
Далее
Every New Vue Developer Has Made These Mistakes...
18:04
Ummmm We "HAIR" You!
00:59
Просмотров 13 млн
▼ЧЁРНАЯ МАГИЯ 🔮
31:15
Просмотров 324 тыс.
What's the Difference Between Vue2 and Vue3?
20:29
Просмотров 15 тыс.
Build your own Custom Composables in Vue
12:13
Просмотров 39 тыс.
Learn TypeScript With Vue.js 3 In 20 Minutes
22:56
Просмотров 74 тыс.