Next.js Modal with Parallel & Intercepting Routes, shadcn/ui Dialog

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ม.ค. 2025

ความคิดเห็น • 131

  • @aliksargsyan2782
    @aliksargsyan2782 7 หลายเดือนก่อน +9

    Even I'm Java Srping Boot software backend engineer, but your content is always intereted me, I appreciate your hard work to bring us such a high quality content. Thank you Dave God Bless you and your family and also welcome back :)

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน +2

      Thank you for the kind words! I'm glad you like my content even though I have not covered Spring Boot!

  • @mistersir3185
    @mistersir3185 6 หลายเดือนก่อน

    I wish I knew about your channel when I was in college, but I'm glad you've decided to chose this path and help us grow as developers. Your contribution brings so much value to people like myself. I've been following your tutorials and there hasn't been a point where I've felt lost. Your teaching style is simple and effective. Loving it!
    Thank you Dave!

  • @joesilva-rodriguez9
    @joesilva-rodriguez9 7 หลายเดือนก่อน +1

    I have everyone that starts with our company to go through your NextJS/Tailwind Course so they can be assets in our teams as fast as possible. Keep em coming!

  • @katiehom
    @katiehom 2 หลายเดือนก่อน

    Thank you, Dave! Watching this and your video on parallel routes helped me to better understand how to open a modal on an intercepted parallel route! I appreciate you sharing your wisdom in an approachable way.

  • @timeforrice
    @timeforrice หลายเดือนก่อน

    Love this short, and precise content!

  • @sibanzboss6705
    @sibanzboss6705 7 หลายเดือนก่อน +11

    yes Dave, we want to see the video about a form in a modal

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน +5

      Thank you!

    • @andrewpaulhart
      @andrewpaulhart 6 หลายเดือนก่อน +1

      Me too. Although I think Ive figured it out, an example of modal login and sign-up forms would be greatly appreciated.

  • @CodeZakk
    @CodeZakk 7 หลายเดือนก่อน +2

    you dropped this when I needed it. i've read the documentation but I didn't understand that much thanks for the video!!

  • @aliassar9647
    @aliassar9647 3 หลายเดือนก่อน

    you always have new lessons to me, though I still read the docs but watching your videos are really helpful to understand more sufficient . Thanx a lot

  • @fatihece3359
    @fatihece3359 2 หลายเดือนก่อน

    Great content, many thanks sir. Learned so much things from your valuable channel

  • @gerrcass1
    @gerrcass1 6 หลายเดือนก่อน

    Enjoy your vacation, cheers to this industry!

  • @aghil_shoja
    @aghil_shoja 7 หลายเดือนก่อน

    Hi Dave, I get very excited when you upload new videos on TH-cam, thank you once again for your invaluable tutorials

  • @g_k_shuvo
    @g_k_shuvo 7 หลายเดือนก่อน

    I appreciate your hard work to bring us such a high quality content. Thank you Dave!

  • @mj95412
    @mj95412 7 หลายเดือนก่อน

    Love the 7 day beard Dave, you definiely deserve it all the work you in

  • @harunadaudq2183
    @harunadaudq2183 7 หลายเดือนก่อน +1

    Really enjoyed this, kindly apply this on form

  • @psyferinc.3573
    @psyferinc.3573 3 หลายเดือนก่อน

    you are guiding in a very understanding way.

  • @idevbrandon
    @idevbrandon 6 หลายเดือนก่อน

    Thank you so much, Dave! Modal was kicking my ass

  • @amadeosph2045
    @amadeosph2045 7 หลายเดือนก่อน

    Hi Dave, I'm from Brazil 🇧🇷 and I'm learning a lot from all your videos..... I really appreciate you making this high quality content. thank you 😁✅

  • @njosuedev.
    @njosuedev. 7 หลายเดือนก่อน +1

    Hello Dave! Thank you

  • @ProCoder777
    @ProCoder777 7 หลายเดือนก่อน

    Привет Дэйв! Спасибо за интересное видео. Очень жду новые выпуски. Ты потрясающий учитель. Спасибо, что делишься своими знаниями со всеми нами.

  • @ilan117
    @ilan117 7 หลายเดือนก่อน

    Alway thank you Dave. I am usually doing that in an e-commerce shop so I can show the product details and of course the check out. I’d be happy if you can show forms and tables as you suggested ❤

  • @MattJenningsChannel
    @MattJenningsChannel 7 หลายเดือนก่อน

    Thanks for the content Dave - would be great to see your approach to editing data tables with modals in NextJS 🙌

  • @justaregularguy2390
    @justaregularguy2390 2 หลายเดือนก่อน

    hi dave, thanks for the guide and yes we would love to watch a video from you about form in a modal mixed with data tables. Thanks

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 หลายเดือนก่อน

      I'm going to have a form in a modal in my current Next.js 15 Project series. The series is underway, but I haven't published that video yet - but it is coming soon.

  • @gopuadks
    @gopuadks 7 หลายเดือนก่อน

    Thank you so much dave i really need this concept and you just drop a this video, how lucky I am

  • @andrewpaulhart
    @andrewpaulhart 6 หลายเดือนก่อน +1

    Great video. Thanks. However I'm having a little trouble wrapping my head around exactly what is happening. I am still confused as to why the modal disappears when we navigate back to the home page, and for that matter why the non modal version isn't showing when the page is first displayed. When using parallel routes to implement a dashboard all the parallel routes are rendered on screen together. Since the modal seems to be implemented as a slot in the layout in the same way, why is it not displayed like all the slots are displayed initially on a dashboard? I'm wondering whether it is the null default.tsx that makes the modal disappear, but you seemed to downplay its significance so that's probably not it. Perhaps, brain cell impaired such as myself, more explanation contrasting the previous modal implementation, ie opening and closing the modal, and the nextjs 14 approach of having the modal always open would be a good.

  • @yourcasualdeveloper
    @yourcasualdeveloper 7 หลายเดือนก่อน +1

    As always when I needed most

  • @Sylar7773
    @Sylar7773 7 หลายเดือนก่อน

    Realy thank You for Your job!!!

  • @mickeykadimov7128
    @mickeykadimov7128 4 หลายเดือนก่อน

    Hey Dave Gary. Very helpful! I would love to see you making a video also about intercepted-searchbar 🙋‍♂🙋‍♂ thank you in advance.

  • @MrRicardosgeral
    @MrRicardosgeral 4 หลายเดือนก่อน

    Yes. Modal with react table. I need it😊

  • @dragonloboJR
    @dragonloboJR 7 หลายเดือนก่อน

    Very useful for ux!

  • @TravinskiyVladislav
    @TravinskiyVladislav 7 หลายเดือนก่อน

    Thank you Dave

  • @rajfekar1514
    @rajfekar1514 7 หลายเดือนก่อน

    thanks for this tutorial.

  • @풍월상신
    @풍월상신 7 หลายเดือนก่อน

    Thanks Dave and welcome back.😊
    This intercepting route is still confusing, maybe I need to write my own code.
    A tutorial video for modal with some form and data will be great.
    What about a MessageBox Modal with Tabs like inbox and send form etc.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      Thank you! And great suggestions. Yes, working with intercepting routes will help you see how they work. In this modal example, we intercept the request for the photo route segment and instead, display the mirrored route in a modal.

  • @uraura8165
    @uraura8165 4 หลายเดือนก่อน

    Hi. Anybody knows how to prevevnt feed page scrolling up when modal window appear?

  • @JimHarris-w2x
    @JimHarris-w2x 6 หลายเดือนก่อน

    This is great, thanks. Could this pattern support returning data or a callback from the modal to the route or component that called it?

  • @danushkap
    @danushkap 7 หลายเดือนก่อน

    Hi Dave, I'm a big fan of yours.
    And I'm very much looking forward to the day you will start a React Native course.

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 7 หลายเดือนก่อน

    Thank you

  • @rusko_
    @rusko_ 6 หลายเดือนก่อน +1

    I always find reloading a page with an open modal to lose its content outside the modal to be frustrating, because I expect the modal to disappear when I refresh the page. Instead, it does the exact opposite, which can be very annoying. Initially, when I encountered this behavior on Instagram, I thought it was a bug.

  • @daretobedangerous6552
    @daretobedangerous6552 หลายเดือนก่อน

    What if we don't want to redirect when the page is refreshed ?

  • @pookiepats
    @pookiepats 7 หลายเดือนก่อน

    Frameworks have just gone off the deep end, respect to anybody that actually has to implement these behemoths.
    I am content writing stored procedures for you to call-just stop trying to run JS in my SQL servers.

  • @vyshnav2488
    @vyshnav2488 7 หลายเดือนก่อน

    sonner and toast component when triggered inside intercepting modal does not pop up or is not visible

  • @ic0mad
    @ic0mad 3 หลายเดือนก่อน

    Is there a way for the exit animation on the modal to play? Right now the modal close instantly with no animation

  • @shakthis-qy8su
    @shakthis-qy8su 7 หลายเดือนก่อน

    you are my awesome Dave

  • @ekchills6948
    @ekchills6948 7 หลายเดือนก่อน

    crazy! please can you do the other application of the modal ((:

  • @eedeenet
    @eedeenet 5 หลายเดือนก่อน +1

    what if i dont want a fallback route /photo/1 should always open the modal?

    • @evheniydan
      @evheniydan 4 หลายเดือนก่อน

      Did you find a solution?

  • @StephenRayner
    @StephenRayner 7 หลายเดือนก่อน

    From my CV, Technology Summary
    Experience: Total industry experience 14 years. Roles 2 years as Director, 3 years as Tech Lead, Full-stack Developer (8 years). AWS (5 years), Typescript/Node (6 years), React/Native (6 years), C# & Python (4 years)
    Current Role: Vercel, NextJS, Inngest, Twilio, Tailwind, ShadCN, Jest, Docker, Apache Superset, VercelAI, LangGraph, OpenAI, ClaudeAI, pgVector, XState, AWS EC2/ECS/S3/VPC/Lambda/SQS/SFN/SNS, Terraform.
    And I still find your videos very useful!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน +1

      You have a great CV and great experience! So glad my content is still helpful for you. I'm sure you could show me a few things, too!

    • @StephenRayner
      @StephenRayner 7 หลายเดือนก่อน

      @@DaveGrayTeachesCode happy to share ideas. You on Discord?

  • @nro337
    @nro337 7 หลายเดือนก่อน

    Great video!

  • @Raul-wf6zf
    @Raul-wf6zf 6 หลายเดือนก่อน

    I am implementing a modal within a modal is this a good idea to do parallel routes?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  6 หลายเดือนก่อน

      A modal within a modal - I'd avoid if possible, but sometimes weird things are necessary. Parallel routes are a good idea for a modal - not sure about layering them.

  • @melkhywong7594
    @melkhywong7594 5 หลายเดือนก่อน

    can this works with shadcn sheet ui?

  • @mahmudulhasan7858
    @mahmudulhasan7858 3 หลายเดือนก่อน

    Great ❤

  • @enziqflow4296
    @enziqflow4296 5 หลายเดือนก่อน

    Any idea how to implement it for dynamic routes?
    For example i have route
    app/
    game/[id]/page.tsx - where i should open modal
    review/[id]/page.tsx target page
    it feels very buggy, and docs are not clear about it

  • @abhim6380
    @abhim6380 7 หลายเดือนก่อน

    How is the coffee list still visible in the background of the modal in route /photo/1?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      That's how modals work - they overlay the page underneath. The shadcn/ui Dialog component applies an overlay that has an opacity setting which lets you see what is underneath. You could customize it.

    • @abhim6380
      @abhim6380 7 หลายเดือนก่อน

      @@DaveGrayTeachesCode but for the route /photo/1 the coffee list shouldn't be displayed. Only the modal should be displayed, No?

  • @prepperdon
    @prepperdon 7 หลายเดือนก่อน

    FYI - intercepting routes in a subdirectory are broken in 14.2.3. They do work in the root of the app though. Fought that bug for about 4 hours yesterday, rolled next back to 14.1 and they work fine.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      Interesting indeed. It must be a specific scenario as I have a work project currently on 14.2.3 which uses a subdirectory (..)route-segment that is working with no issues.

    • @prepperdon
      @prepperdon 7 หลายเดือนก่อน

      @@DaveGrayTeachesCode Could have been my specific scenario, but I did find a few reports in github complaining about the same issue. I was trying to intercept a rout 3 levels deep - /dashboard/questions/edit and it just wouldn't work no matter what I tried.

  • @emmanuelxs6143
    @emmanuelxs6143 7 หลายเดือนก่อน

    Great tutorial, loved it, can you implement said functionality with react and react router dom v6, i have been trying to do sth similar but can't find a working solution, thanks by the way

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      I will take a look in the near future. I'd like to cover RR7/Remix as they are merging.

    • @emmanuelxs6143
      @emmanuelxs6143 7 หลายเดือนก่อน

      @@DaveGrayTeachesCode thanks, I really appreciate

  • @Bangladesh689
    @Bangladesh689 7 หลายเดือนก่อน

    Nice. Thanks.
    What if I have a link inside the modal like previous and next. Then after clicking these link the close button won't close the dialog instead it will keep going back to the history. What would you recommend?

    • @Bangladesh689
      @Bangladesh689 7 หลายเดือนก่อน

      I know that router.push(specificPath) can solve this. But in my case I have login button on navbar and inside the modal I have link to sign up form as well. So I want when user closes the modal they go back from where they came from

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      Not sure that I'm following all of your specifics, but the handle function I introduced in this video should take a user back to where they came from.

    • @lukavrtaric9918
      @lukavrtaric9918 3 หลายเดือนก่อน

      First, do not use the Nextjs component as links for prev/next inside the modal but buttons with onClick methods that use the useRouter() hook. And then when clicking the next/prev buttons do not use the router.push("") but router.replace(""), in that case, router.back(), when closing the modal, will work as expected, since router.replace() provides a client route without adding a new entry into the browser's history.
      Hope this helps

    • @Bangladesh689
      @Bangladesh689 3 หลายเดือนก่อน

      @@lukavrtaric9918 I fixed it by passing the 'replace' prop to the Link component.

  • @ivodelev9794
    @ivodelev9794 7 หลายเดือนก่อน

    Hi and thank for your video. I am still confused as what problem does this solve tho?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน +1

      A modal will display over the current page. In Next.js, you can intercept a route segment and display it in a modal. In business apps, a common use case would be a page with a table of results. You don't want to keep submitting a form to see those results so you keep that page underneath while working with the individual records from the table in a modal that displays a form. Many other uses but this one is common.

  • @Pptruenoz
    @Pptruenoz 7 หลายเดือนก่อน

    You should set the vscode toolbar to the right side or maybe hide it so we can see the code

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  6 หลายเดือนก่อน

      I usually press Alt+Z so all code lines wrap - so they should still be visible?

  • @sujoykrhaldar
    @sujoykrhaldar 7 หลายเดือนก่อน

    Can we do this in React ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน +1

      This is specific to the Next.js framework. Next.js is a React framework.

  • @acloudonthebluestsky9687
    @acloudonthebluestsky9687 25 วันที่ผ่านมา

    Somehow when I implemented this in my real-world project, the @modal is not intercepted; it's redirecting me into the /route/[id] and not showing the modal. :( Anyone have any idea how this happened?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  24 วันที่ผ่านมา

      Double check the route. It is easy to not indicate the correct level like .. or similar.

  • @ogt1407gabriel
    @ogt1407gabriel 7 หลายเดือนก่อน

    You the best

  • @w1erley
    @w1erley 7 หลายเดือนก่อน

    Hello, can you please advise me how I can implement a modal like in twitter when creating a post? It seems to be the same, but when you reload the page, it doesn't show you a new page, instead it shows a modal panel with a dashboard in the background
    Same goes for the profile edit modal, when you click edit, it opens the modal with /settings/profile url, but when the page reloads, the modal is saved but the background changes to the dashboard
    I'd really appreciate your help.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      You can load a modal without an intercepting route. Sounds like that is what you are describing.

  • @rahulchourasiya4148
    @rahulchourasiya4148 7 หลายเดือนก่อน

    Can you please make a video for single sign on, like centralised authentication website using next-auth, without any workos or any paid library for multiple saas website

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      I might someday, but it isn't high on my list because Kinde gives you lots of features and up to 10k users for free. Makes it an easy choice for most of my projects.

    • @rahulchourasiya4148
      @rahulchourasiya4148 7 หลายเดือนก่อน

      @@DaveGrayTeachesCode we are developer, we build own tools instead of relaying other. Thanks

    • @kazmi401
      @kazmi401 7 หลายเดือนก่อน

      @@rahulchourasiya4148 So go ahead Build your own Next-auth. why you are requesting to use it.

  • @rajfekar1514
    @rajfekar1514 7 หลายเดือนก่อน

    Please help me withn nextjs new authjs v5 login with both through Googleprovider and credentials login how to manage both login simultaneously through rest api login.

  • @Malcolm777-i
    @Malcolm777-i 7 หลายเดือนก่อน

    🎉🎉🎉🎉🎉🎉🎉

  • @tareksiddiquenabil5403
    @tareksiddiquenabil5403 7 หลายเดือนก่อน

    ❤❤

  • @IbanTheOne
    @IbanTheOne 2 หลายเดือนก่อน

    I don't get the use of Shadcn or Radix UI Modal components existing HtmlDialog native component. It's just nonsense.

  • @larrymcfarlane6202
    @larrymcfarlane6202 7 หลายเดือนก่อน

    Hmmmm...could be useful for a login form where a session/jwt expired.

  • @anasouardini
    @anasouardini 4 หลายเดือนก่อน

    Isn't this just a pop up with unnecessarily changing the url? I'm failing to see a valid use case of this, a pop up with two buttons "visit" and "share" would render this feature completely unnecessary.
    Perhaps, Nextjs should've made their next/link easier to use like they do in tanstack router instead of baking new features that don't really affect the DX that much.
    Maybe I'm just too dumb to understand this.

  • @thebilalafsar
    @thebilalafsar 7 หลายเดือนก่อน

    Bring the PHP course 😡😭

  • @josephtan6018
    @josephtan6018 7 หลายเดือนก่อน

    Hey Dave,
    Please make a playlist for Remix. It's much much better than NextJS. Thank you.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      I've been wanting to do this. With their new announcements, it might be good to wait for the RRv7 merger.

  • @ofeklevy1242
    @ofeklevy1242 7 หลายเดือนก่อน

    NUM1

  • @hadilibrahim4465
    @hadilibrahim4465 7 หลายเดือนก่อน

    Thank You 🤍✨️
    source code, please ...

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน +1

      I will check - thought I had provided the link, but if not, I'll put it in there ASAP!

    • @hadilibrahim4465
      @hadilibrahim4465 7 หลายเดือนก่อน

      Thanks ✨️🤍😍

  • @ericmensah9037
    @ericmensah9037 7 หลายเดือนก่อน

    Hello Dave at th-cam.com/video/Ft2qs7tOW1k/w-d-xo.html when creating the modal component, since the props defaultOpen and open are boolean, I guess it'll be cleaner to just specify the properties because they'll evaluate to true by default. Thank you.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      Yes in this case. In many instances, you would use a trigger to open the model and then it needs to be able to receive more than one value.

  • @Boss-gr4jw
    @Boss-gr4jw 7 หลายเดือนก่อน +1

    This is such a mess. Why in the hell would you need to create so many nested structures to build something simple. It's literally impossible to understand what belongs together when every component is spread around 10 different directories. Nothing makes sense here, absolutely no locality of behaviour, only technical non-sense.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 หลายเดือนก่อน

      Yeah, the Next.js App Router is opinionated about that. YMMV

  • @ionutsandu5913
    @ionutsandu5913 29 วันที่ผ่านมา

    While I can see how this is useful, I could suggest at least 2 easier ways to implement this. I'm not sure why they made it so complicated. Parallel routes are kinda useless, in my opinion.

  • @toKrzychu
    @toKrzychu 4 หลายเดือนก่อน +1

    Half the video had nothing to do with the modal - totally unnecessary stuff

  • @ricko13
    @ricko13 หลายเดือนก่อน

    way too complicated for such a simple thing

  • @alarafatsiddique9362
    @alarafatsiddique9362 7 หลายเดือนก่อน +5

    Really enjoyed this, kindly apply this on form