Next.js Modal Form w/ React-Hook-Form, ShadCN/ui Dialog, Server Actions & Validation

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

КОМЕНТАРІ • 80

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  5 місяців тому +6

    BIG thanks to daily dot dev for sponsoring this video! 🙌 Stay up-to-date in all things web development with their amazingly free curated web development platform. Check it out here: daily.dev/dave-gray

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

    Been following this channel for almost 3 years now, a pillar of the javascript/react/typescript community, I've followed through the complete nodejs and complete react courses which is where I learnt the dev patterns for the first time. Thank you for sharing your knowledge, hope to teach like you some day

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

    yes modal with a form is needed in almost all projects, thank you for sharing your way

  • @Bratislav_Zdravkovic
    @Bratislav_Zdravkovic 5 місяців тому +3

    I would like to see more Next.js videos, specifically on next-intl with Zod and react-hook-form. What are your thoughts about next-safe-action? Maybe you could provide an example with it. How would you handle prop drilling? For example, if you have a modal with a Select component that needs options fetched from the backend. Also, could you cover some global error handling? When would you use error.ts, and when would you just show a notification?
    Keep up the good work

  • @colinswancs
    @colinswancs 5 місяців тому +3

    Dave, A video on data fetching in Next.js 14 (App Router) would be great. Covering API Routes for webhooks, Server Actions for server-side data fetching, using Server Components with Server Actions for inline fetching, and integrating TanStack Query for client-side data handling. Thanks, for the content. :)

  • @joshuaochieng3091
    @joshuaochieng3091 Місяць тому

    I totally love your tutorials. No matter how long the video I always know in the end I'll definitely get what I came for and even learn more stuff. So I just wanted you to know how helpfull your videos are and that you should keep it up

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

    I am watching your 4hr long HTML tutorial.
    It's great
    Thanks Dave

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

    Hey dave am really a big student of your tutorials since i began my web dev journey.i watched html,css,and javascript and honestly you've really helped me alot bcoz you explain things in a nice easily understable terms and right now i have began listening the react tutorial and i can say am well good knowing react bit by bit following you along your tutorial

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

    I built a similar thing a few weeks ago, a multi step form and keep status and selection on each step. And it’s easy to switch between modal and page. Next.js is pretty flexible.

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

      Nice! And yes, I agree on how flexible it can be for building what you need.

  • @javikuma
    @javikuma 5 місяців тому +3

    Great video! The concepts are very well explained. Thanks, Dave! 💪

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

    About a year ago, I had to build one similar and I checked out the video to see if there is any other way to reactor my code. Turns out it will always be quite a few lines haha. Great video man!

  • @풍월상신
    @풍월상신 5 місяців тому +1

    Thanks Dave. I've waited for this upload!😁

  • @sibanzboss6705
    @sibanzboss6705 5 місяців тому +3

    thanks for the video Dave was very helpful, i'd like to see in futures videos how to create a report or a bill pdf file, and also a video about cron jobs

  • @Chris...S
    @Chris...S 5 місяців тому +2

    Would love to see you cover a Auth.js or Clerk tenant setup

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

    Dave, as always, provides an excellent video! 👏🏻👏🏻👏🏻
    I believe you can discuss more in-depth topics such as Design Patterns with NextJS.

  • @jerebenitez8542
    @jerebenitez8542 4 місяці тому

    Thanks! This solved a huge problem for me. I had implemented this differently and it was ugly lmao. Also instead of doing {flag ? () : null}, you can just do {flag && ()}. Cheers!

  • @alirezakiani1222
    @alirezakiani1222 2 місяці тому

    It was great
    I am waiting for your next videos

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

    just noticed I am not subscribed what?! amazing video once again, Im a Remix child but the latest news made me rethink the next stack

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

      Glad you're here! I am interested in the RR and Remix merger.

  • @WahidulIslam-vh5jr
    @WahidulIslam-vh5jr 5 місяців тому +1

    thanks for this video. so helpful ❤💕

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

    thank you, I've been looking for this

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

    thanks for this video. it help me alot.🌼

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

    As always the best!!! Thank YOU

  • @oscarsangularchannel3956
    @oscarsangularchannel3956 Місяць тому

    Thanks for the video I would like to see how to use tanstack Query and table with same dynamics as here ? Thank you

  •  4 місяці тому

    Hello Dave, I really enjoyed learning from this video, there is one thing though, to populate the form you are passing the id of the user in the URL, but for some other use cases this won't be SEO friendly especially if you have long ids, how we can implement this with clear urls?

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

    Hey @DaveGrayTeachesCode. At 4:45 you say that you need to install the shadcn component one at a time but you know by doing pnpm dlx shadcn-ui@latest add you get prompted with a list and you can select all the components to install at once.

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

      Nice! I never think of it that way because I always install them as I need them which ends up being one at a time lol

  • @NikitaPolovinkin
    @NikitaPolovinkin Місяць тому

    Thanks a lot for this video! Do you know is there is an easy way to enable transitions on intercepted modals? I can not make it work for som reason

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

    Hey Dave, what VS Code theme are you using?

  • @GabrielMartinez-ez9ue
    @GabrielMartinez-ez9ue 15 днів тому

    In case I have a form in a page that is not in a modal, how can I trigger that alert if the user clicked on another url without saving change?

  • @psyferinc.3573
    @psyferinc.3573 Місяць тому

    yay, in depth modals

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

    Hey I am using an application in which I am fetching image links from the database and rendering them
    But as in nextjs we need to keep the Image links in next.config.js how can I solve this
    P.S as i don't want to use aws S3 for storing the image
    Currently I am using the img tag rather than using the next Image

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

      You don't need to keep all links in the next.config.js file. You just need to say what domain those links are coming from. You can see the settings for "remotePatterns" here: nextjs.org/docs/app/api-reference/components/image#remotepatterns

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

      @@DaveGrayTeachesCode Iam working on Job listing project in which I give users authority to post jobs in which the image of the company is uploaded by link input form not the image directly
      Now the user can upload an image of any website or any protocol I can't list everything in next.config.js
      Is there any way of doing it please say for now I am using img tag rather next/Image

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

      @@Md_sadiq_Md Yes interesting question. I would need to look into this to confirm what is possible here.

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

    kindly now as react has 14 version up and running you should update your last video on react or make a shorter version please

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

      Yes, I've been thinking about doing a new React Fundamentals series.

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

    Thanks Dave.. Can we have PWA using nextjs

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

      Interesting topic! I need to look into this 🙌

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

      @@DaveGrayTeachesCode thank you.. Waiting for your valuable tutorial..

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

    Hi Mr Dave, I have a question about the name type for the InputWithLabel component, how can we make it show a type error if we use a name doesn't exist in the schema.

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

      Good question and going the extra mile! You could alter this and use a generic type that accepts the schema. Then nameInSchema would by a keyof the generic. This could be a nice addition.🙌

  • @conanastasiou2568
    @conanastasiou2568 4 місяці тому

    Hi Dave, great video. I was trying to close the Modal on Submit and had a question that I'd like to understand. If I add router. back() to the UserForm onSubmit then the modal closes but the users page won't refresh (even though the changes are saved) however if I use the fallback route directly i.e. /users/edit/1 then this works fine. Any advice?

    • @ciruz
      @ciruz 12 днів тому

      in the server action on save you can revalidate the list page like revalidatePath(`/users`), and on the client side in the onSubmit, you do your router.back(). then you have the fresh data in the list

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

    Thanks for this Dave. A quick one, what if I have a button on the modal to view the full page, will I have to perform a full page reload? setting the modal to false just closes the modal but doesn't push to the the page. i.e I still have the route '/user/edit/1' but the content displayed is that of '/user'

    • @ciruz
      @ciruz 12 днів тому

      use revalidatePath(`/user`) in your server save action and router.back() in the onSubmit handler on the client side after the save

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

    What is the difference between using Next.js with Server Actions and Next.js with Hono.js?

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

      Hono provides a separate backend. You could still use server actions with Next.js and handle API routes with Hono.

  • @OnlyJavascript
    @OnlyJavascript 2 місяці тому

    i love your content so much. I have a request. could you please do it for us? server side search, sort, multi-filter and pagination using shandcn table component and tanstack table. please use drizzle orm.

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

    Can you make full next 15 course cuz I want to learn next but didnt find a one. "I know you published full one but it's 13"😊

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

      Next.js 15 is still a release candidate, but when it is released I may create an entire new course. Thanks for the request!

  • @rebeldes96
    @rebeldes96 13 днів тому

    I cloned your repo, did 'npm install' then follow your video, but I was getting a error: "message": "Expected number, received string"
    when clicking on "View Users" from getUsers file...
    I think zod-fetch is returning "id" as string, searching in stackOverflow I found a solution: add ".coerce" at id UserSchema:
    Before:
    export const UserSchema = z.object({
    id: z.number().int().positive(),
    firstname: z
    After:
    export const UserSchema = z.object({
    id: z.coerce.number().int().positive(),
    firstname: z
    Hope this help someone with same issue...

  • @oladapooluwadurotimi2865
    @oladapooluwadurotimi2865 5 місяців тому +2

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

    Really how to implement Nextjs auth with without third party libraries like kindle or lucia and add how to implement RBAC .That is saying how to Roll your own Auth.also how to dockerize nextjs project and add reverse proxy like ngnix or caddy and Host on a VPS.

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

      Good advanced topic requests!

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

      Delta (that’s her channel name), has an excellent roll-your-own Next JS auth video which she uploaded only 2 days ago (13 June 24). She explains how to do it properly, not a high level copy and paste exercise.

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

    Nice

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

    Next make an image gallery app with modal popup with prev and next navigation