Vue 3 Composition API Introduction [FULL TUTORIAL]

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2024
  • The Composition API is THE biggest new feature introduced by Vue.js 3. It's 100% optional but definitely worth a closer look as it allows you to write leaner, more elegant code - especially in bigger apps and components.
    Starting Code: github.com/aca...
    Finished Code: github.com/aca...
    Learn ALL about Vue 3 (incl. deep dives into the Composition API) with my fully updated course: acad.link/vuejs
    Also learn about all other import changes introduced by Vue 3: • Video
    Check out all our other courses: academind.com/...
    ----------
    • Go to www.academind.com and subscribe to our newsletter to stay updated and to get exclusive content & discounts
    • Follow @maxedapps and @academind_real on Twitter
    • Follow @academind_real on Instagram: / academind_real
    • Join our Facebook community on / academindchannel
    See you in the videos!
    ----------
    Academind is your source for online education in the areas of web development, frontend web development, backend web development, programming, coding and data science! No matter if you are looking for a tutorial, a course, a crash course, an introduction, an online tutorial or any related video, we try our best to offer you the content you are looking for. Our topics include Angular, React, Vue, Html, CSS, JavaScript, TypeScript, Redux, Nuxt.js, RxJs, Bootstrap, Laravel, Node.js, Progressive Web Apps (PWA), Ionic, React Native, Regular Expressions (RegEx), Stencil, Power BI, Amazon Web Services (AWS), Firebase or other topics, make sure to have a look at this channel or at academind.com to find the learning resource of your choice!

Комментарии •

  • @yazilimokusaydin
    @yazilimokusaydin 3 года назад +44

    7:04 Ref (Reactive data initiation)
    9:40 Computed props
    11:05 Methods
    16:25 Inherited props
    18:35 Emitting events to parent component
    19:34 Watchers

  • @boomerangfish3558
    @boomerangfish3558 4 года назад +14

    Thank you very much.
    To me, the simplicity of the Options API is the magic of Vue, so I will stick to that.

  • @samstubeshorts
    @samstubeshorts 4 года назад +42

    Max, I am an IT professional. Last year my income was only 3.25 lakhs (INR) in a year. I started watching your course, learned, practiced, and worked hard. Now as a result I am earning more than 30 lakhs (INR) per annum. It's just only because of you. No words can express how grateful I am. #therealteacher

    • @Kingside88
      @Kingside88 3 года назад +3

      Please don't compare you're luck on this earth with the eternity.
      Jesus Christ died for you're sins and if you would get him, you would never compare a man with God.

    • @xavier.whisper.underneath
      @xavier.whisper.underneath 2 года назад +12

      @@Kingside88 WTF

    • @CJCJCJCJ
      @CJCJCJCJ 2 года назад +4

      @@Kingside88 cringe

    • @zainmushtaq4347
      @zainmushtaq4347 2 года назад

      @@Kingside88 In the grand scheme of things, you could say that God (or first cause/luck/whatever) "pushed" that first domino brick that would eventually help Sam out through the videos of Academind, so in that sense, I agree with you.
      As for Jesus Christ being God, doesn't that contradict your last statement of "you would never compare a man with God"? If Jesus Christ behaved, acted, spoke, ate and prayed just like any other human being (or any other prophet with miracles), how could you possibly compare this man-like created creature with the uncreated and eternal God?

    • @Kingside88
      @Kingside88 2 года назад

      @@zainmushtaq4347 Jesus is not half human and half God. As soon as he born he became a full human. And still was God and son of God. And he is still both. You can not find anybody to compare with him.

  • @billtudor1953
    @billtudor1953 Год назад

    This video is still useful today!
    I found it after spending a week spinning my tires learning Vue. I bought the course on Udemy for $15 and Section 19: Replace the Options API taught me everything I needed.
    Thanks for taking the time to build this series.

  • @leytnerj
    @leytnerj 4 года назад

    I made my company to buy the IONIC-React course thanks to the 3 hours video, I was a wonderfull work of art, I'm still following it in your page.

  • @dileeppal4849
    @dileeppal4849 4 года назад +8

    I always look for you whenever see new thing happening in React, Vue and Angular and javascript also, what a way you teach i love it. I became a developer in few month by purchasing your courses, you are the only one who has changed me to become a good developer, keep it up best support from us.

  • @dac5961
    @dac5961 Год назад

    This is the best video on how to migrate from Options API to Composition API. Thank you so much for this. Irony is that I already have bought Udemy course on Angular and Vue from you but I usually learns from such short video's here and there 😅

  • @TheHermitHacker
    @TheHermitHacker 4 года назад +9

    I've been struggling to adopt Vue 3 as i'm working on a PWA game project and wanted to adopt the next version. I normally use jQuery or vanilla JS for projects, not having used Vue or React before. Thank you for uploading this video. It's helping me understand everything just a bit better.

  • @adrian-4767
    @adrian-4767 4 года назад +4

    Academind beg/implore you launch a "Complete web developer bootcamp" course from zero to hero. It's going to be a "best seller", it's much needed.

  • @ShivanshTalwar
    @ShivanshTalwar 4 года назад +34

    Was waiting for max to release some beautiful content on vue3 ❤️

  • @vodupit
    @vodupit Год назад +1

    As always, Maximilian is the best in explaining everything :)

  • @mokkabonna
    @mokkabonna 3 года назад

    This is basically how knockout works. Create standalone observables, computeds and method, and expose what you want to the view. Knockout is ofc lacking things like the vdom and other things, but at the core this is how the reactive/observable model works.

  • @PartyBrudeeeer
    @PartyBrudeeeer 3 года назад

    Very good and clean course. I did totally understand everything neccessary under 30mins in order to port/migrate from OPTIONS to COMPOSTION API! Thumbs up

  • @kushalgolhani2161
    @kushalgolhani2161 3 года назад

    I wasn't aware about Max...but after I have gone through this post....It's fab!! I surely started following him in Udemy for other courses. Nicely explained the new concept of composition api

  • @balajisv4052
    @balajisv4052 4 года назад +12

    Was just waiting to ask the doubt of how this kind of compositions helps in improving the application code. And, you just circled it out explaining that in the last 5 mins.

  • @wilsenhc
    @wilsenhc 4 года назад +10

    I love your videos man, I was struggling to understand the Vue 3 Composition API and this just helped me finally understand it!
    I'm saving up to buy your Vue Course now (I already have the PWA and Angular ones)

  • @igorb5774
    @igorb5774 2 года назад +4

    Hi Maximilian,
    I am watching your Vue course on Udemy, so thanks for it, it's a very good one.
    Now I am in the Composition API section, and I have such question:
    I have a lot of experience with React+hooks, and when in Vue I see such things like:
    1) we have both 'ref' and 'reactive';
    2) we need to pass the whole 'reactive' object to make it reactive in the template;
    3) we need to wrap 'reactive' object with 'toRefs' to make its values be reactive;
    4) in the child component we can mutate the 'ref' value injected from the parent component;
    5) when I use some prop in the 'setup' method of child component I should remember whether it is a 'ref' or 'reactive' to know whether to use it with '.value' or not;
    Compared with React, the Vue solution seems to be not so mature and looks more like a workaround, because in React it is solved with a single 'useState' and works much better and obvious:
    - we have "[state, setState] = useState(...)" and with 'setState' we can do any change no matter whether the value is an object or a primitive and it will be reactive;
    - and if talking about the item 4) we just pass via props or context the 'state' if we want it to be read-only, or 'setState' if we want to update the value
    What do you think about this? What is your personal opinion about these things in Vue compared to React?
    BTW. I saw that in Vue docks they compared Vue composition API to React hooks and said how the first is better in terms of performance and etc., But still, IMHO, the developer experience provided by Vue Composition API is not the best one.

    • @Alex1s1
      @Alex1s1 2 года назад

      I‘m coming from Svelte and from that perspective it‘s inadequately solved in both. I have needed the last few days to wrap my head around all those things you mentioned and I‘m still having a problem I can’t figure out.

  • @sandrorosso2165
    @sandrorosso2165 4 года назад +1

    Well Max after being a self taught dev for a year and following mostly your courses i've got hired in honestly the best company i could ever find. I wonder if i should send you at least a bottle of Prosecco. Do you like white wine? 😂

    • @academind
      @academind  4 года назад +2

      I love wine in all colors :D
      Congrats on the job - that's really awesome to read!

  • @alexandros-markovits
    @alexandros-markovits 4 года назад +2

    Oh, didn't know you updated the course! That's awesome! Maybe send a notification in Udemy or email to the users for others who might have missed it too. Can't wait for Nuxt 3 to be released too. Thank you for the video and all the efforts, cheers!

    • @academind
      @academind  4 года назад

      An announcement was sent today to all enrolled students.

    • @alexandros-markovits
      @alexandros-markovits 4 года назад

      @@academind Indeed i see the announcement now, it just doesn't appear in the notifications in Udemy (like usually) for some reason.

  • @crazyidea9143
    @crazyidea9143 4 года назад

    so far this is best tutorial I see in youtube. You explained it pretty simple.

  • @SinisterSlay1
    @SinisterSlay1 4 года назад

    New APIs use seems to be if you don't want to make components out of everything. I can see a good use in combining the two methods in 1 component. Composition API to share code, and options API to effectively extend the shared code.

    • @KylanHurt
      @KylanHurt Год назад

      But how exactly would you share some code with the composition API? Is the assumption that you will import one more more methods / variables from the returned 'setup' object into other components?
      Maybe it's just me but I don't see a ton of benefit to this if I still have to be import more stuff (ref), extracting their values (.value), etc. I guess I was expecting something a little more impactful than this.

  • @mkli3459
    @mkli3459 Год назад

    Once again, guaranteed Maximilian quality! 👌

  • @theilluminatimember8896
    @theilluminatimember8896 3 года назад

    This "hooks" thing is what really blew my mind

  • @kenmoultonjr.
    @kenmoultonjr. 11 месяцев назад

    This info is prime, and your video is superb... although I am getting some serious Nick Kroll vibes, vocally. It's kinda like learning to program with Prof. Poopypants from Captain Underpants. Love it!

  • @kasperskyns
    @kasperskyns 2 года назад

    Came across you video and really love the way you explain things. Will certainly get your course now.

  • @RaoVenu
    @RaoVenu 2 года назад

    Thanks sounds very similar to React hooks and the last example which he mentioned sounded like a custom hook. Nice

  • @habibsspirit
    @habibsspirit 4 года назад +13

    It's astonishing to me how Max's brain is able to hold so much information.

    • @seanraz
      @seanraz 3 года назад

      I think quite often when watching his videos!

    • @RameenFallschirmjager
      @RameenFallschirmjager 3 года назад

      codes are written in his DNA!

  • @jorden123
    @jorden123 3 года назад

    Comprehensive explanation, thanks for that!

  • @user-oh4xi2xb2d
    @user-oh4xi2xb2d 3 года назад

    In big app good aproach to make search mixin with data, methods etc for search, filter mixin with data, methods etc, check premissions mixin etc

  • @LeopoldoErick
    @LeopoldoErick 2 года назад

    Thank you for the introduction, it was very helpful. 💕

  • @norwegiancamper2800
    @norwegiancamper2800 2 года назад

    Perfectly explained, thanks!

  • @kott8888
    @kott8888 Год назад

    Awesome as always!

  • @OAzraai
    @OAzraai 4 года назад

    Excellent video! Love the way you explained things. Many thanks Max!

  • @monogalaxia
    @monogalaxia 3 года назад

    Finally I understand it! Thanks

  • @derhighland6528
    @derhighland6528 3 года назад

    Now use typescript and tsx and you have a beautiful setup ;)

  • @danvilela
    @danvilela 4 года назад

    Finally i get this! Thank you bro!

  • @willfranklyn2
    @willfranklyn2 4 года назад +10

    Interesting changes. Are there any benefits to using a setup() instead of the separate data(), computed() and methods()? Almost seems a bit more complex than the separate functions. Also not a huge fan of having to use refs for all data variables and having to add value when using them.

    • @willfranklyn2
      @willfranklyn2 4 года назад +3

      Sent this before I finished the video. I see how it can be useful to simplify the logic used by multiple components.

    • @jored56
      @jored56 4 года назад +1

      @@willfranklyn2 he elided a bit but some people actually prefer the reactive() function instead, which is meant to wrap objects. So something like
      const x = ref(1);
      x.value = 2;
      can be replaced instead with
      const data = reactive({ x: 1 });
      data.x = 2;
      for roughly the same effect. Of course there are some pros and cons for each, but for simple components they should be mostly interchangeable.

    • @Sk8nRock
      @Sk8nRock 2 года назад

      My thoughts exactly. But even after watching until the end I am still not sure that the benefits outweight all the extra work and added complexity. It's a bit dissapointing that the Vue team decided to follow the hooks trend introduced by React instead of coming up with a cleaner solution.

  • @ludwingguate
    @ludwingguate 4 года назад

    Thanks Max! Your explanation is amazing.

  • @_the_one_1
    @_the_one_1 4 года назад +22

    Hey Max, now that Vue is becoming the greatest FE framework (My opinion of course) is any plan on a new Vue 3 course with typescript + end to end and unit tests ?

    • @academind
      @academind  4 года назад +10

      Not right now. Maybe I can add sections to the existing course - not in the next weeks though.

    • @TheStefanos939
      @TheStefanos939 4 года назад +7

      @@academind yeah just add 2 sections of testing and typescript in the existing course! That would be awesome! Also thanks for updating your course!

    • @levi4thon
      @levi4thon 4 года назад +3

      @@TheStefanos939 The documentation is really great. You should also check out lmiller1990.github.io/vue-testing-handbook/v3/ for a Unit Testing intro.

  • @marcelhajjar4893
    @marcelhajjar4893 2 года назад +2

    i think composition api might be good, but for me options API is an organized and simpler to read and use;

  • @Tuzike
    @Tuzike 2 года назад

    Thank you man, appreciate the video!

  • @KillerKingdom
    @KillerKingdom 4 года назад

    After long long time

  • @Infinitude
    @Infinitude 4 года назад

    Awesome content of vue 3 at the same time. Loved the content.

  • @ElmachitoSilbateador
    @ElmachitoSilbateador 4 года назад

    It would be nice a video using instead of the setup() function

  • @alenamekhnina-marcalle5234
    @alenamekhnina-marcalle5234 4 года назад

    So no Angular and React goals? :D I have listened to your Vue course and it is the best that I found. After the course I was looking for information how to manage code for bigger Vue applications, but there is so little information out there, or maybe I was looking in wrong places. I also did not find any courses online that would give me that knowledge. I would really appreciate if you could create a video/extra chapter in your course with tips/tricks for bigger applications. And thanks a lot for all your hard work!

  • @shahmirjadoon3587
    @shahmirjadoon3587 4 года назад +1

    Hello Max!
    Any idea of sharing this Vue 3 course on Udemy ?

  • @webstylepress
    @webstylepress 4 года назад

    Great tutorial MAX. Posting less on RUclips lately.

  • @YarCoder
    @YarCoder 4 года назад +2

    great explanation

  • @adamsaime-desire7240
    @adamsaime-desire7240 3 года назад

    Thanks man, I know understand Vue composition Api

  • @gilbert.gabriel
    @gilbert.gabriel 2 года назад

    Great Tutorial!

  • @dil-jay
    @dil-jay 3 года назад

    Thanks for this great tutorial

  • @sealone777
    @sealone777 4 года назад +4

    Thanks Max! Has vue gain more popularity? these days it's hard to find new content related to Vue and basically it's just React. Also, any thoughts on NestJS as your next course? Lots of buzz around that framework. Supposely a better version of express.

  • @half841
    @half841 4 года назад +4

    Now when Vue 3 is out, is there a plan maybe for MEVN course Max :) ?

    • @academind
      @academind  4 года назад +2

      I got no concrete plans but it's something I'd like to do, I can say that.

  • @QQ-wv3gz
    @QQ-wv3gz 4 года назад +1

    Can we expect some php course on academind any soon?

  • @YCMJasonCodes
    @YCMJasonCodes 4 года назад

    very well explained! good job 👍

  • @nihilidron
    @nihilidron 2 года назад

    Options API is much more intuitive and causes less pain.

  • @AlTheHat
    @AlTheHat 2 года назад +8

    Vue 3 honestly seems like a step backwards to me. Less seperation of concerns, more ambiguous data access (having to use .value on a ref), all seems a bit odd. Personally I like simple Vue 2 with vuex for state management, and the built-in event bus for broadcasting actions. Much simpler.

  • @rajikkali2381
    @rajikkali2381 3 года назад +19

    Anyone else prefer the options API like 10,000 times more than the composition API? Updates to frameworks should make coding in them LESS verbose, not more.

    • @k.safonov
      @k.safonov 3 года назад +5

      Composition API is much much much better than options API for 1 simple reason - all of the logic related to certain part of the component can be grouped in one single compact place so you don't need to scroll back and forth all the time so understand how certain part of the component works.

    • @rajikkali2381
      @rajikkali2381 3 года назад +7

      @@k.safonov That’s a reason I actually don’t like the composition API. I like data in data, methods in methods, computed in computed. Also, I HATE having to import ref, define ref and const for everything… feels like old vanilla JS.

    • @blakerunyon09
      @blakerunyon09 Год назад

      That exactly why I like it. It’s a lot more like JavaScript, a lot less like a framework.

    • @rajikkali2381
      @rajikkali2381 Год назад +1

      @@blakerunyon09 sounds like you want React

    • @himurakenshin9875
      @himurakenshin9875 Год назад

      ​@@rajikkali2381No he wants a better React. Secondly removing this keyword from code is an improvement friend. this keyword sucks in js

  • @theblahbutinihead1504
    @theblahbutinihead1504 4 года назад

    Can you please do more videos on flutter like to add the name of the application with code etc like how to publish the application too...

  • @PaulMcKillop
    @PaulMcKillop 4 года назад +1

    Hey Max, are you planning an Ionic/Vue course like the really good React course?

  • @inHague
    @inHague 7 месяцев назад

    thank you !😃😃

  • @nero1375
    @nero1375 4 года назад

    Perfectly timing! heheee
    Thank you Max!

  • @rchjsh
    @rchjsh 3 года назад

    Is this easier? Seems like more steps?
    Edit: nvm watched the whole video, this is beautiful, vue for life💚

  • @amerrashed6287
    @amerrashed6287 4 года назад +1

    Hi Max, are u going to update the most successful vue js course on udemy with latest vue js 3 changes?!
    I hope so as usually expected ☺️🙏🏼

    • @academind
      @academind  4 года назад +1

      I just updated the course to Vue 3.

  • @TheBeezerbutt
    @TheBeezerbutt 2 года назад

    Super!

  • @batbawls
    @batbawls 3 года назад

    Well done

  • @israelumeadi5995
    @israelumeadi5995 4 года назад +1

    Awesome content

  • @imlautaro123
    @imlautaro123 3 года назад

    Great video 👍

  • @DodaGarcia
    @DodaGarcia 3 года назад

    I cackled at the app filtering out any React and Angular related goals lmao

  • @Velastroll
    @Velastroll 3 года назад

    TY bro 👍🏻

  • @shaneomoore
    @shaneomoore 4 года назад +9

    Ahhh Vue Hooks I see :D

  • @J-HAYER
    @J-HAYER 3 года назад

    Max, do you prefer the composition api or mixins for code reusability?

  • @kirindev
    @kirindev 3 года назад

    thank you.

  • @beeo9964
    @beeo9964 4 года назад

    Hi Max! I would like to know if you can make a shorter version of React course, focusing more on the most important aspects of it?

  • @anjaan7664
    @anjaan7664 3 года назад

    Very good

  • @zeeshanafzal8565
    @zeeshanafzal8565 2 года назад

    please share your course link?

  • @yun-ruzeng5026
    @yun-ruzeng5026 3 года назад

    gooooooood!

  • @mizanur_sajid
    @mizanur_sajid 4 года назад

    Hey Max! I have a request to you...please make a course on web design with HTML5 & CSS3 for beginners...actually the courses of web design on udemy are old and not good as I want

  • @manfredschmidt5450
    @manfredschmidt5450 3 года назад +2

    I really don't fully understand the benefits of this composition approach.

  • @marovo2419
    @marovo2419 3 года назад

    Well explained. Good work! Feedback for improvement: Think about working on
    pronunciation (improve the "chewing gum" english and unrelaxed way of talking). I like the content of Max a lot, but unfortunatelly I just can't listen to this pronuncation for a whole course (eg on Udemy)

  • @gbasbu
    @gbasbu 4 года назад

    Thanks

  • @tkskates
    @tkskates 4 года назад

    Great video! Quick question.. Can I use a hook in app.vue if I convert it to composition api? Right now I find I need to call the same code at app start up as when navigating to a component. I've been using mixins for this.

  • @محمودعبدالخالق-ع3س
    @محمودعبدالخالق-ع3س 4 года назад

    great jop
    do you have any plan for golang ?

  • @shashiverma6219
    @shashiverma6219 4 года назад

    Thanks max

  • @JY-xv7ic
    @JY-xv7ic 4 года назад

    hi, please create a video about jobs queue with nodejs or express..

  • @kasvith
    @kasvith 4 года назад

    thanks max

  • @himanshuagarwal5259
    @himanshuagarwal5259 4 года назад

    Hey Max, Thank you for such an amazing tutorial. Can you help me out with a live location tracking application(idea about to go with it )?(using node js as backend)

  • @kristofszobacsi5123
    @kristofszobacsi5123 3 года назад +1

    someone could explain to me why is it better using this setup() where i have to import everything one by one to use the damn thing instead of using the normal data, computed, methods etc?? instead of making things easier i find this to be much more of a pain in the ass personally and yet have not found any advantages

  • @KylanHurt
    @KylanHurt Год назад

    How on Earth would this make code-sharing easier? The mixins for the options API seemed pretty darned convenient...

  • @ionscorobogaci5530
    @ionscorobogaci5530 3 года назад +1

    so did you get what composition api provides ? you just talked about replacing old with new, but what this new bring to the table ? I've seen only refactoring the code, but nothing valuable on this composition api, but this might be my personal view on this, sorry

  • @andonandonov7793
    @andonandonov7793 3 года назад

    I want to tripple like this tutorial xD

  • @JustSkiv
    @JustSkiv 4 года назад

    Academind, Can you tell me what software you use to record parts of the video that look like a presentation? With beautiful tables, diagrams, images, text, etc.

  • @rutshah8710
    @rutshah8710 4 года назад

    Hey Max,
    I missed out early when membership launched. Is it possible to get the yearly membership at introductory price in near future?
    Current price is a bit stretched for me due to higher currently price deficit between USD and INR.
    Thank you.

  • @nasreenustad7658
    @nasreenustad7658 4 года назад

    First comment from my side Max

  • @miguelqueiroz5415
    @miguelqueiroz5415 3 года назад

    But that userSearch could not be imported either without the composition API? anyways?

  • @jouchiwinchester2666
    @jouchiwinchester2666 4 года назад

    Hi,
    I would like to ask why context doesn't have a root in my vue 3 setup. when i console.log (context) it only displays emit, slot and attr. there is no root in there. thanks

  • @Snitovets
    @Snitovets 3 года назад

    The main thing located in the end of the video.

  • @aminsoraya
    @aminsoraya 3 года назад

    very useful tutorial. very nice and then subscribe to your channel

  • @fahad.hossain
    @fahad.hossain 4 года назад

    Please a video in Angular 10.

  • @ulvihmdli688
    @ulvihmdli688 4 года назад

    i download codes and opened it in visualstudio vue code's color is gray i dont know why please help me