React Hook Form (+ Zod) - Complete Tutorial

Поділитися
Вставка
  • Опубліковано 23 гру 2024

КОМЕНТАРІ • 143

  • @ByteGrad
    @ByteGrad  10 місяців тому +5

    My Professional React & Next.js course is OUT NOW now! Find it here: bytegrad.com/courses/professional-react-nextjs -- this is the #1 resource to master the latest React & Next.js, my absolute best work.

    • @ilukanets
      @ilukanets 5 місяців тому

      I'm from Ukraine and just visited your course page. Want to thank you for supporting Ukraine by providing special coupon, I believe there are people who need it. Thank you!! And your videos are great, especially this one. Great job!

  • @TheLondekZdroj
    @TheLondekZdroj Рік тому +34

    Man! you are a lifesaver. There's nobody else on YT who can compress so much useful knowledge in an easily digestible format. Well done!.

  • @FGA-47
    @FGA-47 Рік тому +88

    This tutorial is by far the most exceptional one I've come across. The meticulous breakdown into step-by-step segments and the incredible effort you invested in creating it are truly remarkable. Thank you immensely for your dedication. Please continue the great work!

    • @thegoncaloalves
      @thegoncaloalves Рік тому +2

      It was definitely not easy to find a good tutorial for nextjs, react-hook-form and zod. This is a great resource!

  • @editin232
    @editin232 Рік тому +23

    You going trough the traditional way of creating a form is so useful to me as a new developer.

  • @Fishamble
    @Fishamble Рік тому +4

    I think I am finally at the stage where I can appreciate the videos you make. They had gone over my head in the past, but now I find them excellent. Thanks and keep up the good work.

  • @rogue-02
    @rogue-02 Рік тому +8

    I love the way you explain the Why's we moved from one approach to another in ur videos... For example here with why from traditional controlled component to react hook form to react hook form with zod...u can't imagine how valuable that is so we don't just memorize patterns without knowing why we do things a certain way... Keep up the good work man

  • @ameyasanyal5965
    @ameyasanyal5965 2 місяці тому +1

    Your tutorials are so flawless, descriptive, it doesn't seem like some human is making them.

  • @Julia_K7
    @Julia_K7 Рік тому +11

    This is an amazing tutorial! I tried watching a few different ones about react-hook-form and zod before this one and none of them could explain the topic as clearly as you did!

  • @VLADICA94KG
    @VLADICA94KG Рік тому +10

    I can't emphasize enough how invaluable your videos are and how much I learned from them. Thanks a lot and keep up the great work!

  • @SaurabhThapliyal-pu3vs
    @SaurabhThapliyal-pu3vs 10 місяців тому +1

    I must say, this UA-cam tutorial on React Hook Form and Zod validation is hands down the best beginner-friendly resource I've come across! The explanations were crystal clear, and I now have a solid understanding of how to integrate these tools into my projects. Huge thanks to you Sir!

  • @musiuralamopu9589
    @musiuralamopu9589 11 місяців тому +2

    I hardly comment on videos. But this channel is a gem store surely! Mentioning actual issue, resolving with robust and sophisticated solution and also no unnecessary single words! Very very grateful to you! 🖤

  • @AlexanderBelov-y8o
    @AlexanderBelov-y8o Рік тому +3

    Waoh, single handedly teaching React form validation in 30 minutes with clear explaination.

  • @TheStallion1319
    @TheStallion1319 2 місяці тому +1

    Amazing and straight to point, it's equivalent to hours of other courses.

  • @Milo_1010_
    @Milo_1010_ Рік тому +2

    I just discovered your channel and i have to say it is the most clean and comprehensive tutorial i had on React Hook Form. Thank you a lot for your dedication, i just subscribed !🎉

  • @songhyeonjun2803
    @songhyeonjun2803 Рік тому +8

    this course is really well organized and should be popular more!

  • @АртурХабибулин-ъ4д

    Very clear and accessible explanation, with a live example. Everything is strictly to the point, without unnecessary water. Thank you very much!!!

  • @abdullah_siddiquii
    @abdullah_siddiquii Рік тому +8

    The way of your teaching is superb. Firstly see whats the problem is by brute force Solution then think why to shift and how to shift toward clean and efficient solution.

  • @alterickoo
    @alterickoo Рік тому +3

    Really enjoyed the way you structurally explained the concepts and in a beginner friendly way. This is a great tutorial! Thanks man!

  • @captainnoyaux
    @captainnoyaux 11 місяців тому +2

    I love your content I'm forwarding it to my colleagues that don't know yet some stuff you cover, thanks a lot !

  • @jrmayol857
    @jrmayol857 Рік тому +4

    Awesome vid! The calmness of the voice, zen mode.

  • @mohamaduhadijatu736
    @mohamaduhadijatu736 5 місяців тому +1

    This channel's content is next level . I really appreciate your work.

  • @VincentFulco
    @VincentFulco Рік тому +6

    Outstanding, clear, concise. Kudos!

  • @janpapaj4373
    @janpapaj4373 8 місяців тому +1

    You are the GOAT of nextjs tutorials, amazing

  • @edh9500
    @edh9500 7 місяців тому +1

    You're a savage!! Thanks so much. Every sentence is valuable. On top of learning what I need to do, I pick up so many tips in how you write you code that I advance as a developer.

  • @zubaydullookhunboboev8576
    @zubaydullookhunboboev8576 Рік тому +3

    Amazing tutorial. Your way of understanding by comparison from traditional to modern form with react hook form is great methodology. Thanks bro!

  • @ericaugusto5640
    @ericaugusto5640 11 місяців тому +1

    What an amazing tutorial, it's always easier for me to understand a concept when the problem is presented first. Thanks!

  • @neilmerchant2796
    @neilmerchant2796 Рік тому +3

    I really appreciate how effectively you explain every step and all surrounding context. 12/10

  • @demembree
    @demembree Рік тому

    Been stuck for one week with the first method (without library) and state not updating well, errors still displaying when the form is well filled. You saved me! You have the best react video.

  • @lehoangtuan613
    @lehoangtuan613 29 днів тому +1

    Thank you so much!
    Your explanation is so clear, step by step and easy to understand and follow.

  • @spongebob93lover
    @spongebob93lover Рік тому +1

    awesome tutorial!! I really like that you showed the traditional way of dealing with forms and compared the before/after. The explanation is very detailed and helpful for beginners. thank you!

  • @Teckstudio
    @Teckstudio Рік тому +4

    Awesome tutorial! As always!!! I love what you are doing 😍
    One remark to the error field of zod: There is the function .flatten() which reduces the overcomplicated zodError to a simple object with the keys .formErrors and .fieldErrors. Just using that .fieldErrors as the return value would then make your code much cleaner in my eyes. I only mention this because .flatten() is overlooked in many zod-tutorials even though it is really usefull. 👍
    Something like this:
    //On the server
    if(!res.success) return res.error.flatten().fieldErrors;
    //On the client (where errs is the return object from the server)
    for (let [key, err] of Object.entries(errs)) setError(key as any, { type: "server", message: err[0] });

    • @nasarissa749
      @nasarissa749 Рік тому

      What do you do when err[0] is of type 'unknown'

  • @DanielEmenikeCodes
    @DanielEmenikeCodes Рік тому +5

    Your explanations are top-notch! Just subscribed. Thanks for the fine details

  • @elianismedina
    @elianismedina Рік тому +1

    Thanks a lot for this video, very professional. You are a really good teacher . I understood everything. I have been watching your video for a while and I feel you are a pro

  • @viniciusm.m.7822
    @viniciusm.m.7822 Рік тому +1

    3:21 man, that's amazing, I've never seen it or even thought about it!
    Forte abraço do Brasil!
    God bless!

  • @rounakbhattacherjee5288
    @rounakbhattacherjee5288 9 місяців тому +1

    You earned a subscriber, what an explanation bro, what a comparison , keep up the good work buddy! Love from India❤

  • @ceeesmack
    @ceeesmack 11 місяців тому

    I play this before I go to sleep because the monotone voice can help me fall asleep. I also played it to learn react hook form. It's a very good video for that too! ; )

  • @rezaainulzaki9651
    @rezaainulzaki9651 Рік тому +4

    as always, you explained really well and beginner friendly

  • @ytfriends7448
    @ytfriends7448 11 місяців тому

    I dont know why people are missing such a good channel thanks for the video by the way💜

  • @alsherifkhalaf7385
    @alsherifkhalaf7385 8 місяців тому +1

    You are simplify things and this helps me understand very well ❤🎉

  • @supafast1314
    @supafast1314 Рік тому +1

    It was a very good amount of value in a single and fast video, thank you! However It would be great if you make a Part ll adding a solution like SWR or React Query to handle the Fetch/mutation logic and talk about the that solutions as well as it is a great topic too! Thank agan 🙏

  • @AcromondX
    @AcromondX Рік тому +2

    I love your style of teaching

  • @rangerboi9715
    @rangerboi9715 Рік тому +1

    Hey Wesley! Good day I loved your tutorial could you also show us how to work with forms where we need an array of forms when we need to fill for situations like adding multiple users.

  • @this-is-clem-fandango
    @this-is-clem-fandango Рік тому +1

    instant subscribe you're such a good teacher

  • @pasinduvinsuka
    @pasinduvinsuka Рік тому +1

    The way you are explaining things are amazing 🔥🔥❤❤

  • @gedeonyala6836
    @gedeonyala6836 4 місяці тому +1

    if it was possible to give a thousands of likes i would do it, thanks a lot for this amazing knowledge big bro

  • @youneshenni5417
    @youneshenni5417 Рік тому +1

    You're becoming one of my favourite dev youtubers. PS you might need a better microphone.

  • @treyrader
    @treyrader 10 місяців тому +1

    Gosh man you're such a pro! totally a wizard

  • @SugengWahyudi
    @SugengWahyudi Рік тому +1

    really clear tutorial. Your way explains is amazing

  • @techlearner-hs3ft
    @techlearner-hs3ft 7 місяців тому +1

    u really have great explanations, thanks a lot for helping me understanding react🙌

    • @ByteGrad
      @ByteGrad  7 місяців тому

      Happy to help!

  • @davida8216
    @davida8216 Місяць тому +1

    amazing, thanks for showing all sides

  • @ezetenduwilliams7322
    @ezetenduwilliams7322 Рік тому +2

    Good job bro. This was detailed properly. I'd start using zod. +1 subscriber for you

  • @123123123tomiasd1231
    @123123123tomiasd1231 Рік тому +1

    Great video with great examples!!! loved it

  • @alionar60
    @alionar60 Рік тому +1

    Wow! You're great, you explained it so well!

  • @buraxta_
    @buraxta_ 8 місяців тому +1

    You're the best, we love you!

  • @nick-ui
    @nick-ui Рік тому +2

    This is really great example how to use zod with hook form package

  • @lalasca6358
    @lalasca6358 Рік тому +1

    Thanks.. Grad great explanation.

  • @chukwuemekamusic663
    @chukwuemekamusic663 3 місяці тому +1

    wow... great one! thank you

  • @learner8084
    @learner8084 8 місяців тому +1

    Very useful video. Thank you !
    I used formik before. In formik, I can wrap the component so that I can have multiple level components and I can still pass the name of the field down and I can access formik. How can I achieve the same in React Hook Form ? Thanks.

  • @Fanaro
    @Fanaro Рік тому +3

    Dang, with Zod, this looks really sharp.

  • @meka4996
    @meka4996 Рік тому +2

    Amazing!!! You are the man!

  • @Julieyudowitch
    @Julieyudowitch Рік тому +2

    Thank-you this was very easy to follow

  • @ivanfranciscoj
    @ivanfranciscoj Рік тому +1

    I think I love you bro, great tutorial. 👍🏻

  • @b-vo8zf
    @b-vo8zf Рік тому +1

    I love your videos. They always help me. Could you make a video about React Hook Form + Zod + React Select / Creatable, please?

  • @eliucastillo6976
    @eliucastillo6976 5 місяців тому +1

    Bro, this is Gold (y)

  • @rishavsharma4206
    @rishavsharma4206 Рік тому +1

    Hey Wesley,
    Fantastic content, have been looking for this tutorial and you my dear friend, nails every topic that you teach. 💓
    Would love to follow along with some initial code. Although, you have provided the final code, it would be great if you share initial code as well in a branch so we can also follow and code while learning from you.
    P.S. Please keep showering us with your knowledge. I am saving money to buy the new Next.js and React course, hopefully will be able to see you there as well. Thanks for everything Wesley 🖤

  • @wasimrafik3535
    @wasimrafik3535 Рік тому +1

    first video liked it so much so just subscribed it

  • @mohdsahil226
    @mohdsahil226 Рік тому

    Thank you! Would you please do it with NextJs Server Actions instead of API route?

  • @BritainRitten
    @BritainRitten Рік тому +2

    Excellent walkthrough

  • @sandrogtz
    @sandrogtz Рік тому +1

    This was unbelievable helpful

  • @dannydg1985
    @dannydg1985 5 місяців тому

    How do you implement this when also using server actions with useFormSate / useActionSate? I currently have an implementation using a client-side form action that calls trigger of react-hooks-form to validate the form.

  • @0xtz_
    @0xtz_ Рік тому +5

    👏🔥 amazing video 👏

  • @HenryBabbage
    @HenryBabbage Рік тому +2

    Exactly the video I needed

  • @shteev
    @shteev Рік тому +1

    Is it possible to do forms and form validation if you're using server components? I imagine you'd have to split the inputs out into use client components, but then how does it get connected to the useForm hook?

  • @adnanamin3666
    @adnanamin3666 Рік тому +2

    The best! 👌😊

  • @dhirajavasthi6539
    @dhirajavasthi6539 Рік тому +1

    your content is very helpful can you please help me with the below problem using zod and next js 13 or 14
    problem: How to read content of uploaded json file on react / next.js 13 or 14 using zod

  • @abdelfadeel0
    @abdelfadeel0 Рік тому +1

    Great explanation

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 6 місяців тому +1

    Thanks man, you're legend

  • @yuvalazaria
    @yuvalazaria 11 місяців тому +1

    Just great🎉 thank you very much

  • @alexreyes-cn9ru
    @alexreyes-cn9ru Рік тому

    this is great, I just got a question, can you tell us something about react-hook-forms with EXPO

  • @pheisar
    @pheisar Рік тому +1

    so between using a server action and api post route, you'd recommend using a route handler?

    • @ByteGrad
      @ByteGrad  Рік тому +4

      I don’t have a strong opinion on that now, but in future server actions will be the standard. I used route handler in this video because more people will be familiar with it

  • @ahmedkaram3829
    @ahmedkaram3829 Рік тому +2

    good video and nice to share this knowledge

  • @fooked1
    @fooked1 Рік тому

    Any advice on handling localization with Zod and RHF?

  • @CistiC0987
    @CistiC0987 Рік тому +3

    Great video! How can I get your nextjs course? From what I've seen from you, it has to be a good stuff

    • @ByteGrad
      @ByteGrad  Рік тому +4

      Thanks. It’s coming out soon. 😉 Make sure you’re on the email list

  • @wolfie8748
    @wolfie8748 21 день тому +1

    Super super super helpful

  • @NeerajShukla-t8n
    @NeerajShukla-t8n 6 місяців тому +1

    Superb thank you sir..

  • @zaeemahmad910
    @zaeemahmad910 6 місяців тому

    well explained
    Subscribed 💚

  • @saifullahrahman
    @saifullahrahman Рік тому

    There is one problem with this, .optional() wont work to make a field not required.
    I had to use a workaround for this.
    Any idea why it doesnt work?
    Also if the input is number, it gives errors.

  • @dimitro.cardellini
    @dimitro.cardellini 4 місяці тому

    Pretty nice video.
    But, I do have one concern about needing the same schema for both the front-end and back-end.
    In my experience, it doesn't work that way.
    First, the set of fields can be different.
    For example, the back-end doesn't need the confirmPassword field.
    Second, the field names might not match.
    If the server uses snake case, the front-end doesn't necessarily have to follow suit.
    Third, the message format can differ even if the rules are the same.
    For instance, the front-end needs to support localization, whereas the back-end might only respond in English.
    Fourth, the rules can differ, and the reactions to them must also be different.
    For example, should we really display "Expected string, but received number" to the user?
    In this case, we should show "Something went wrong" and report the issue to Sentry (or
    another error reporting system), as it indicates a potential client-server integration
    issue that needs fixing.
    These differences exist because the goals of validation are different.
    Front-end validation aims to help users input correct data, while server-side validation ensures the data is correct.
    So, please consider using different schemas for front-end and back-end validation.

  •  Рік тому

    Will the async method handleSubmit be awaited or how does that work, is the handle event prepare for async methods?

  • @MrBl0m
    @MrBl0m Рік тому +1

    Thanks !

  • @abukhalidrifat3994
    @abukhalidrifat3994 7 місяців тому

    During server side validations I need to manually check using if condition. Is there any shortcut for that?

  • @dubekone
    @dubekone Рік тому

    Hello did you know if .refine can have multiple validations?, for example in the video u use .refine((data) => validation, {message, path}) how could i do multiple validations?

  • @keristang7208
    @keristang7208 11 місяців тому

    Hi im newbie of nodejs, nextjs , i saw when you type in the visual studio code there is intellisence. how you got all the intellisense like visual studio. what plugin do you install?

  • @naveedalirehmani4135
    @naveedalirehmani4135 Рік тому

    Great video, can you also make a video explaining how to use react-hook-forms with a UI library or a Framework? maybe shadcn.

  • @ollebergkvist8538
    @ollebergkvist8538 Рік тому

    valibot is a less than 1kb type-safe alternative to zod (very similiar api), i believe that's a better package to use for client-side forms if you want to make sure to get good first load js values :) zod is quite a heavy package that's more suitable to implement server-side until they fix the bundlesize...

  • @UP209D
    @UP209D Рік тому +1

    Should we use different returned http code for the one with errors

  • @tonyeneh8194
    @tonyeneh8194 6 місяців тому +1

    awesome! Thanks a lot

  • @yokuna-b5m
    @yokuna-b5m 11 місяців тому

    Hello. What kind or name is there with the vscode extensions auto-complete code.

  • @27sosite73
    @27sosite73 Рік тому +1

    thank you

  • @nutshellggdarken7114
    @nutshellggdarken7114 Рік тому

    What do you use to get the autocomplete feature in vscode? :O