Build a Multistep Form in NextJs Using react-hook-form and ZOD

  Рет қаралды 35,934

Hamed Bahram

Hamed Bahram

Күн бұрын

Пікірлер: 119
@MiladJoodi
@MiladJoodi 4 күн бұрын
You really explain things easily. I believe that some people are born to be teachers.🙌✨
@hamedbahram
@hamedbahram 3 күн бұрын
Thank you!
@raillyhugo3287
@raillyhugo3287 7 ай бұрын
Thank you, that's what exactly I was looking for. Concise and clear explanation! Keep up the good work!
@hamedbahram
@hamedbahram 7 ай бұрын
Great to hear that!
@longsuabc
@longsuabc 11 ай бұрын
Really great and amazing video. Very clear explanations all the time. I am not a native English, but I can hear his English very clearly!! I respect you and your business!!! Cheers!!! From China! 💪💪✨✨👍👍👏👏
@hamedbahram
@hamedbahram 11 ай бұрын
Great to hear that! Welcome to the channel.
@BreadfortheSoul-lb3zr
@BreadfortheSoul-lb3zr 4 ай бұрын
Thank you for taking the time to share this. The Lord Jesus bless you.
@hamedbahram
@hamedbahram 4 ай бұрын
My pleasure! Glad it helped.
@jeremiahchinwe1336
@jeremiahchinwe1336 4 ай бұрын
This video has really helped me achieve my task
@hamedbahram
@hamedbahram 4 ай бұрын
Very glad to hear that.
@INetreba
@INetreba 14 күн бұрын
Thank you! I like your vibe
@hamedbahram
@hamedbahram 14 күн бұрын
Anytime!
@almaducatel5830
@almaducatel5830 4 ай бұрын
Thank you verry much for your time. You are a blessing.
@hamedbahram
@hamedbahram 4 ай бұрын
You are very welcome!
@leonardorocchini9012
@leonardorocchini9012 11 ай бұрын
Nice video. that would be great to implement app routing in the multistep form so that we have a separate page for each step.
@hamedbahram
@hamedbahram 11 ай бұрын
For sure!
@raymondmichael4987
@raymondmichael4987 3 ай бұрын
🤔🤔 actually that’s a good idea, I have several ways to leverage it “I guess “😊
@alexavery8182
@alexavery8182 10 ай бұрын
Hamed always delivers great content
@hamedbahram
@hamedbahram 10 ай бұрын
Appreciate that!
@sundayucheawaji6206
@sundayucheawaji6206 4 ай бұрын
Thanks for this. It was really helpful.
@hamedbahram
@hamedbahram 4 ай бұрын
Glad it was helpful!
@yogawithaaron
@yogawithaaron 5 ай бұрын
This video was tremendously helpful. Ty!
@hamedbahram
@hamedbahram 5 ай бұрын
Glad it was helpful!
@irfansaeedkhan7242
@irfansaeedkhan7242 3 ай бұрын
too much code in one component killed the main motive of react, it would have better to also show if each form is in different component because form could be bigger
@hamedbahram
@hamedbahram 3 ай бұрын
This video is not so much about React component composition but more so about the concept of a multi-step form implemented using react-hook-form and zod for validation.
@raymondmichael4987
@raymondmichael4987 3 ай бұрын
Using multiple forms for this lesson would have made the video too complicated for me. I think for delivering the intended concept, he chose the best approach. Once we understand the concept it’ll be much easier to na split the form into much smaller forms as we want and he mentioned it clearly 😊
@raymondmichael4987
@raymondmichael4987 3 ай бұрын
@@hamedbahramthanks man, keep them coming ❤
@OutrospectiveOfficial
@OutrospectiveOfficial 2 ай бұрын
Excellent content, thank you!
@hamedbahram
@hamedbahram 2 ай бұрын
Glad it was helpful!
@ammarhaidar5995
@ammarhaidar5995 11 ай бұрын
Awesome, just in time🎉🎉, appreciate your content, thanx.
@hamedbahram
@hamedbahram 11 ай бұрын
Glad to hear that!
@alir8zana635
@alir8zana635 10 ай бұрын
thank you so much for this video it really helped me implement it in my own project your videos are great and I hope you great success
@hamedbahram
@hamedbahram 10 ай бұрын
You're very welcome! I'm glad it helped, and I appreciate your comment!
@htetlinlinnaing4994
@htetlinlinnaing4994 3 ай бұрын
Thank you for your amazing Next.js content! If you have time, could you make a tutorial on adding/removing multiple fields dynamically on button click? It would be super helpful!
@hamedbahram
@hamedbahram 3 ай бұрын
My pleasure! Do you mean adding conditional steps?
@htetlinlinnaing4994
@htetlinlinnaing4994 3 ай бұрын
@@hamedbahram I meant a form where I can add or remove multiple fields dynamically, like adding or removing phone number fields on button click. Thank!
@raymondmichael4987
@raymondmichael4987 3 ай бұрын
I think you mean handling fieldArray 😊. it’s a good one to learn from expert.
@yasserhy
@yasserhy 11 ай бұрын
As always, brilliant video ❤
@hamedbahram
@hamedbahram 11 ай бұрын
Thank you! Cheers!
@almaducatel5830
@almaducatel5830 4 ай бұрын
As always He save me.
@alextwin200e3
@alextwin200e3 8 ай бұрын
Thank you very much! It helped me a lot. Great content!
@hamedbahram
@hamedbahram 8 ай бұрын
You're welcome! Glad it helped!
@ivandamyanov
@ivandamyanov 7 ай бұрын
Thanks for the great video. I really like react-hook-form but there seem to be very few videos about an important integration - custom inputs + react hook form. I read 3 different articles for different versions of the library and it is all implemented differently and some things don't work. Especially with a Typescript environment. I like that library but it proves to be very complicated for beginners to use it in a reusable way (custom components). Would be awesome if you could do a short video on that or redirect me to any good example you might know of for the latest version.
@hamedbahram
@hamedbahram 7 ай бұрын
Tell me more... are you using a UI library for your custom components?
@kyle-andrewgovinder9902
@kyle-andrewgovinder9902 11 ай бұрын
Always providing us with amazing content, Hamed It's safe to say you taught me everything I know about Next
@hamedbahram
@hamedbahram 11 ай бұрын
Glad to hear that! I appreciate your comment.
@hqasmei
@hqasmei 11 ай бұрын
Another great video, thanks Hamed!
@hamedbahram
@hamedbahram 11 ай бұрын
I appreciate it, Hosna! What is similar to how you implemented it?
@siebe681
@siebe681 11 ай бұрын
This was something I was searching for! Thank you!
@hamedbahram
@hamedbahram 11 ай бұрын
You're welcome!
@imkir4n
@imkir4n 11 ай бұрын
Wow i was looking for the same🔥
@hamedbahram
@hamedbahram 11 ай бұрын
There you have it!
@kristian970
@kristian970 11 ай бұрын
Great video! Thank you!
@hamedbahram
@hamedbahram 11 ай бұрын
You're welcome!
@usamausman5225
@usamausman5225 11 ай бұрын
Please make a complete series on Next 14
@hamedbahram
@hamedbahram 11 ай бұрын
Everything is the same in NextJs 14, nothing has changed :) The only change is that server actions are now stable. But I'll make a video reviewing the release.
@YasamanKarbasi
@YasamanKarbasi 4 ай бұрын
THANK UUU
@hamedbahram
@hamedbahram 4 ай бұрын
Anytime!
@SanderCokart
@SanderCokart 11 ай бұрын
We need a version that cam scale infinitely using lazy and pre loading but idk how you preload component 3 while component 2 is showing for example.
@hamedbahram
@hamedbahram 11 ай бұрын
Maybe have them as different components and lazy load the components and pass the promise to the form component. Just thinking out loud here...
@tomasburian6550
@tomasburian6550 2 ай бұрын
What always gives me hard time is trying to figure out some extra features that would fit into the process because as a pro I tend to get tasks that are easily out of the ordinary use case. For example, I want the user to input his company number on the first step and then not only validate that the input is not empty, but also that the number they provided is real and not made up. Is there a way to run a custom function for each step that would do something before it would let the user go on to the next step?
@hamedbahram
@hamedbahram 2 ай бұрын
Yes you can have custom validation for each field.
@arezootony9715
@arezootony9715 7 ай бұрын
Amazing video. How do we disable the buttons in each step if the required fields are not filled ?
@hamedbahram
@hamedbahram 7 ай бұрын
Thank you! You can look at the `formState` returned from the `useFrom` hook.
@arezootony9715
@arezootony9715 7 ай бұрын
@@hamedbahram I tried isValid and isDirty but they do not work properly and I think the reason is they are matching with the whole Zod schema and not the items on the page.
@hamedbahram
@hamedbahram 7 ай бұрын
​@@arezootony9715 seem like the solution would be to have separate forms for each step and hold the collected data in a global state.
@arezootony9715
@arezootony9715 7 ай бұрын
@@hamedbahram yes, that is exactly how I was doing with the forms I have. My only problem is keeping the form state when the user goes back to the previous form/step and see the form filled.
@hamedbahram
@hamedbahram 7 ай бұрын
@@arezootony9715 you need to lift the state of the form up to the parent or a global state.
@leilamohamadpor3481
@leilamohamadpor3481 10 ай бұрын
خیلی عالی بود.این چیزی بود که من الان داشتم دنبال آن می گشتم من یک فرم با تعداد خیلی زیادی المنت دارم که باید مقادیر آنها را از کاربر دریافت کنم آیا به نظر شما لازم است که از state management ها استفاده کنم؟ اگر راهنمایی ب فرمایید ممنون می شوم
@hamedbahram
@hamedbahram 10 ай бұрын
Khoshhaalam Leila Jan! Welcome to the channel 🙂
@trusht
@trusht 11 ай бұрын
Thanks sir for the detailed explanation. I have tailwinds subscription so decided to apply this to my app. I am thinking to save input data to local storage just in case if the user navigates away with tons of information typed and when they come back to the form without frustration. What do you think?
@hamedbahram
@hamedbahram 11 ай бұрын
That's great idea Tacettin! I'd love for you to contribute to this project. Open a PR for the storage.
@dosamuel-mb
@dosamuel-mb 4 ай бұрын
Hello, i added a button to submit the data to the API, but i can't even see my data in the console, i can't even log them and there is no error at all. Can someone help please ?
@hamedbahram
@hamedbahram 4 ай бұрын
Clone my code and see what you're doing differently.
@saiguna6676
@saiguna6676 2 ай бұрын
Thank you for the amazing video but if i have optional fields it's not working for that one how to solve it sir
@hamedbahram
@hamedbahram 2 ай бұрын
What is an optional field, one that's not required you mean?
@user-gm3lg8gp3m
@user-gm3lg8gp3m 4 ай бұрын
thank you
@hamedbahram
@hamedbahram 4 ай бұрын
My pleasure!
@kyleroath
@kyleroath 8 ай бұрын
I know this weird, but I kept thinking like damn that chair looks comfy. Can anyone identify which chair that is?
@hamedbahram
@hamedbahram 8 ай бұрын
Haha 😅 Its from IKEA, the model name is Markus.
@kyleroath
@kyleroath 8 ай бұрын
@@hamedbahram ha thank you sir. sorry for the weirdness, thanks for the vid too!
@hamedbahram
@hamedbahram 8 ай бұрын
@@kyleroath no worries!
@davidfarah
@davidfarah 9 ай бұрын
Thanks
@hamedbahram
@hamedbahram 9 ай бұрын
You're welcome!
@AmitErandole
@AmitErandole Ай бұрын
What if we need to show errors while the user is typing? Do we enable the onChange mode on react hook form?
@hamedbahram
@hamedbahram Ай бұрын
You can set the mode to onChange or separate the steps to individual forms.
@AmitErandole
@AmitErandole Ай бұрын
@@hamedbahram ok will try that. Thank you for sharing your repos. They are quite helpful
@kennethlau8108
@kennethlau8108 7 ай бұрын
If we add a file upload input for example in step2 clicked next tp step3 and click back. It will have an error.
@hamedbahram
@hamedbahram 7 ай бұрын
Yeah this isn't a one-size-fits-all solution, you'd have to handle file inputs probably with separate forms for each step.
@kennethlau8108
@kennethlau8108 7 ай бұрын
@@hamedbahram any recommended ways to do so ?
@hamedbahram
@hamedbahram 7 ай бұрын
@@kennethlau8108 watch this → kzbin.info/www/bejne/eZaknKuMrNisg7c
@dogcodes
@dogcodes 6 ай бұрын
Is there a way to remove the validation error message when the user inputs again after validation. So after the "is required" is shown then when I type again that message is not rendered
@hamedbahram
@hamedbahram 6 ай бұрын
You can pass `mode:"onchange"` or if you don't want to trigger state update on change, you can separate each step to an individual form and hold a global state for all the steps.
@dogcodes
@dogcodes 6 ай бұрын
@@hamedbahram Thank you!
@imkir4n
@imkir4n 10 ай бұрын
12:05 hamed why the error is keep complaining even after user entered into the field?
@hamedbahram
@hamedbahram 10 ай бұрын
You can set the `mode` to `onChange` to update the error as the user corrects it.
@imkir4n
@imkir4n 10 ай бұрын
@@hamedbahram Thanks it worked. But Will this lead to multiple re-renders?
@hamedbahram
@hamedbahram 10 ай бұрын
@@imkir4n Yup it does. I don't know of any other way to watch the changes on the fields to wipe out the errors once we triggered the validation.
@dhirajavasthi6539
@dhirajavasthi6539 10 ай бұрын
Hello @hamedbahram your content is very helpful can you please help me in below problam 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
@hamedbahram
@hamedbahram 10 ай бұрын
Not sure if I understand that. Zod is for validating or parsing an object, what do you mean by reading a json file?
@abdulmalikzihad3542
@abdulmalikzihad3542 8 ай бұрын
Will the 2nd step submit the automatically?
@hamedbahram
@hamedbahram 8 ай бұрын
Yes if it passes the validation it submits the form.
@navjotsingh2457
@navjotsingh2457 8 ай бұрын
tysm
@hamedbahram
@hamedbahram 8 ай бұрын
?
@juniorsemerzier660
@juniorsemerzier660 10 ай бұрын
how to remove the error message after the correction of the input value?
@hamedbahram
@hamedbahram 10 ай бұрын
You can pass mode: "onChange" to the `useForm` hook.
@codingwithlucy
@codingwithlucy 9 ай бұрын
@@hamedbahram I was just coming to ask the same question. What do you mean? Do you mean that on every form field you would use trigger on onChange?
@hamedbahram
@hamedbahram 9 ай бұрын
​@@codingwithlucy What I meant is to pass the `mode` property to the `useForm` hook like so ↓ ``` const { register, trigger, ... } = useForm({ ... mode: "onChange" ... }) ``` Does this answer your question?
@AravindK-tv5rh
@AravindK-tv5rh 9 ай бұрын
@@hamedbahram Isn't there any other way? like how it works normally in react hook form for a normal form...
@hamedbahram
@hamedbahram 9 ай бұрын
@@AravindK-tv5rh I'm not aware of any other way! Let me know if you could come up with something else from the docs.
@OmarDugha-o6l
@OmarDugha-o6l 9 ай бұрын
❤❤❤
@hamedbahram
@hamedbahram 9 ай бұрын
❤️
@dolapojohnsonn
@dolapojohnsonn 6 ай бұрын
Nice content. But can I get access to the github repo please?
@hamedbahram
@hamedbahram 6 ай бұрын
Link to repo is in the video description.
@dolapojohnsonn
@dolapojohnsonn 6 ай бұрын
@@hamedbahram Thank you, I'm grateful
@АнтонКобелев-з5ъ
@АнтонКобелев-з5ъ 11 ай бұрын
Do you have this code on git hub?
@hamedbahram
@hamedbahram 11 ай бұрын
Yes the link is in the video description.
@mathuraditya7
@mathuraditya7 11 ай бұрын
Hey, have you tried @rafty/ui for UI?
@hamedbahram
@hamedbahram 11 ай бұрын
Unfortunately not!
React Hook Form - Complete Tutorial (with Zod)
28:22
Cosden Solutions
Рет қаралды 116 М.
Global State Management in NextJs 14 Using Zustand
51:17
Hamed Bahram
Рет қаралды 29 М.
Man Mocks Wife's Exercise Routine, Faces Embarrassment at Work #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 4,4 МЛН
哈莉奎因怎么变骷髅了#小丑 #shorts
00:19
好人小丑
Рет қаралды 52 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 84 МЛН
Ozoda - Lada (Official Music Video)
06:07
Ozoda
Рет қаралды 10 МЛН
React Hook Form & React 19 Form Actions, The Right Way
16:08
Jack Herrington
Рет қаралды 52 М.
Multistep Form Custom Hook With React And TypeScript
28:23
Web Dev Simplified
Рет қаралды 151 М.
ATOMIC DESIGN with REACT and TAILWIND
39:36
Tomasz Buszewski
Рет қаралды 611
Using React Hook Form, Zod Validation and Server Actions in NextJs
25:55
Can I Create This Complex Animated Multistep Form?
39:42
Web Dev Simplified
Рет қаралды 299 М.
React Hook Form (+ Zod) - Complete Tutorial
31:21
ByteGrad
Рет қаралды 97 М.
Create your own Next.js Starter Template
2:35:29
Syntax
Рет қаралды 20 М.
Multi-Step form with react-hook-form
24:07
Austin Shelby
Рет қаралды 43 М.
Reusable Create & Edit Form in React (React Hook Form, Zod)
16:46
Cosden Solutions
Рет қаралды 28 М.
NextJS Just Changed API Routing
0:51
Jack Herrington
Рет қаралды 133 М.
Man Mocks Wife's Exercise Routine, Faces Embarrassment at Work #shorts
00:32
Fabiosa Best Lifehacks
Рет қаралды 4,4 МЛН