Nested Layouts in NextJs 13 Using Route Groups

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

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

  • @zubairahmed2660
    @zubairahmed2660 3 หลายเดือนก่อน +1

    Sir, I really love 😍 the way you edit your videos and teach us. You give half a frame to your video and half to the artwork; it's unique and gives me more attention to learn. After some time, you keep making eye contact with the camera lens. It looks like you are teaching us physically.

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

      Glad to hear that man!

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

    having the layout.tsx right in the app folder was screwing everything up in my project. now i understood it needs to be in a group layout! just putting it in a (root) group layout did it for me.
    thanks a lot

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

      Glad it helped!

  • @sergey_c
    @sergey_c ปีที่แล้ว +1

    Thank you for your explanation! Your example is clear and easy to understand.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      You're welcome! Glad you found it helpful.

  • @alexeysmirnov9288
    @alexeysmirnov9288 9 หลายเดือนก่อน +1

    One more time you've helped me, Hamed. Thanks, bro!

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

      My pleasure! It's great to hear that :)

  • @SajidAliSoftwareEngineer
    @SajidAliSoftwareEngineer ปีที่แล้ว +1

    Thank you so much. Your content is always very entertaining and helpful.

  • @silicongen
    @silicongen ปีที่แล้ว

    Great video! You just made this mess a lot more structured.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Thanks! Glad it was helpful.

  • @sanazniamati2025
    @sanazniamati2025 ปีที่แล้ว +1

    Thank you Hamed , very helpful information

  • @ashishmaharia
    @ashishmaharia ปีที่แล้ว +1

    Loved ur videos brother, so easy to understand.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Thanks, I appreciate your comment.

  • @themodernmonk7
    @themodernmonk7 ปีที่แล้ว

    That's what I was looking. Thanks Hamed. Easy explanation.

  • @altacultura5269
    @altacultura5269 9 หลายเดือนก่อน +1

    Great content!

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

      My pleasure!

  • @kianooshsoleimani5472
    @kianooshsoleimani5472 9 หลายเดือนก่อน +1

    hey hamed, thank you for your explanation, would you please tell how to ignore main layout for some pages?

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

      You can create different root layout for each route group.

  • @stevehyuga9216
    @stevehyuga9216 ปีที่แล้ว +1

    Very good content! Thanks.

  • @erasmusmensah
    @erasmusmensah ปีที่แล้ว

    thanks your for this simple explanation

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Glad you found it helpful

  • @ShubhamTiwari-s4f
    @ShubhamTiwari-s4f ปีที่แล้ว +1

    how to get the data from rest api for a nested layout. For example, the nav menu, if they are coming from backend, how to handle that scenario?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      You can fetch data inside your nested layout.

  • @curiousprogrammer90
    @curiousprogrammer90 ปีที่แล้ว

    Nice, thanks for the useful info! :)

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Glad you found it useful. I appreciate your comment.

  • @nbo304
    @nbo304 ปีที่แล้ว +1

    Have you experienced fonts not loading correctly when you navigate from one layout to another? i have a hero with a next google font and it loads fine initially, but then when i go from another layout back to home page with the hero section, the font fails to load. Any ideas?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Try loading the fonts in your root layout.

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

    Thank you for nice explanation, i am trying to handle to hide navbar in rootLayOut and i am getting hydration error, is there any luck to pass props to layout from page

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

      You can create two root layouts using route groups. Watch the video I have about route groups.

  • @kukiponosanhrvat
    @kukiponosanhrvat ปีที่แล้ว +2

    Excellent video!
    I'm doing something similar in my project. I have two root layouts (auth) and (root). In (auth) route group I've got @authModals sloth and in it (.)log-in and (.)sign-up segments. Also in (auth) I've got segments log-in and sign-up.
    (root) route group is just the rest of the code, which is not really important.
    Problem is when i have parallel and intercepting routes in route group which is also a root layout (one of more), things break and start working unpredictably.
    When i had only one root layout intercepting and parallel routes worked as expected.
    Got any experience with this or idea why this happens?

    • @kukiponosanhrvat
      @kukiponosanhrvat ปีที่แล้ว

      Let me explain you a bit more of how it acts. It's like when im activating modal link from (auth) layout it pops up as modal - for example (.)log-in segment is activated, but when i activate modal from (root) layout it goes to the to the log-in segment directly, and i'm expecting it to go to the (.)log-in.
      It should be going to log-in only on refresh or if user entered url directly if i got it right.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      I haven't tested intercepting routes inside route groups with two root layouts. However, I'm working on a video on this topic, and I'll try to cover this in there.

    • @kukiponosanhrvat
      @kukiponosanhrvat ปีที่แล้ว +1

      @@hamedbahram Nice, can't wait to see your next video!

    • @kukiponosanhrvat
      @kukiponosanhrvat ปีที่แล้ว

      One more thing that i also tried and can't really find any solution anywhere...
      Do you have any idea how to disable intercepting routes on mobile browser (small screens), cuz when I use intercepting routes on desktop browser (modals pop up) and that same behavior is on mobile, which is not wanted...
      As far as i tried Link and router are both in all cases intercepting route and opening the modal...
      The concept it self is really cool, but i don't think it is really production ready yet, especially in these very particular use cases, but idk, maybe I'm wrong and just using it the wrong way. @@hamedbahram​

  • @praneethkumar6506
    @praneethkumar6506 ปีที่แล้ว +1

    Bro, while accessing routes inside route group. I am getting 404 page. I am not sure, why it is behaving like that. I tried the exact same way, just by wrapping the folder around parenthesis and using layout.ts inside it.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      You need a `page.js` inside each route segment. For example:
      (company)
      layout.ks
      About
      page.js

  • @SajidAliSoftwareEngineer
    @SajidAliSoftwareEngineer ปีที่แล้ว +1

    one question may I know which font you are using in VS Code?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      font is Operator mono.

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

    Sir... i've got this error
    You cannot have two parallel pages that resolve to the same path. Please check /(backOffice)/dashboard/(customers)/page and /(backOffice)/dashboard/(merchants)/page
    i've check all route and i'm not find same path on my code

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

      The two paths you provided here both result in `/dashboard/page`. Route groups (when you wrap the folder with brackets) does not affect the path.

  • @rafin_rahman
    @rafin_rahman ปีที่แล้ว

    nicely explaine!

  • @webdeveloper2795
    @webdeveloper2795 ปีที่แล้ว +1

    But how to opt specific segment from RootLayout, can you please explain it

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      You can create multiple root layout, one for each route group. I demonstrated this concept in this video => th-cam.com/video/wnrGmNDNVvM/w-d-xo.html

  • @massoudsharifi2341
    @massoudsharifi2341 ปีที่แล้ว +1

    nic, but how we can send props from different props from page to the layout file ?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      You can't pass props from a page to the layout. Was that your question?

    • @massoudsharifi2341
      @massoudsharifi2341 ปีที่แล้ว

      @@hamedbahram yes, it was

  • @thenoorcrownofficial
    @thenoorcrownofficial ปีที่แล้ว +1

    What happens when we put a route group in a normal route folder in a nested fashion?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Can you expand on your question...

  • @techs7296
    @techs7296 ปีที่แล้ว +1

    Hey bro, can I make Dashboard with this model?

  • @pablom8854
    @pablom8854 ปีที่แล้ว

    route groups not working for me, I'm usign the pages router with next 13

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      Route groups are for the App router.

  • @tseringlama2146
    @tseringlama2146 ปีที่แล้ว +1

    hello brother please make a video on (express js) backend and (next js ) frontend about "server side " filtering data and pagination not using server action

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Thanks for the suggestion. I'll keep that in mind for the upcoming videos.

  • @Dext-err
    @Dext-err ปีที่แล้ว +1

    yeah but how to exclude all layouts for a specific page?

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      You have to create route groups with more than one root layout.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      You have to create route groups with more than one root layout.

  • @ahmedhassan_saver
    @ahmedhassan_saver ปีที่แล้ว

    Can't i just create folders with no page.tsx inside them and then add folders with page.tsx inside?
    Is the descending page.tsx files won't be detected?

    • @ahmedhassan_saver
      @ahmedhassan_saver ปีที่แล้ว

      I will continue the video and see
      Thanks man 🙏

    • @speedster784
      @speedster784 ปีที่แล้ว

      ​@@ahmedhassan_saveronce you create a folder in the app directory it automatically becomes a part of the routing system so therefore grouping is needed to ignore such cases

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      The page will be detected but the parent folder would create a route segment in the URL.

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Exactly 💯

  • @udaym4204
    @udaym4204 ปีที่แล้ว

    Hello sir please make video on next js opengraph and twitter image card

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      I'll have that in mind. Thanks for your suggestion Uday.

    • @udaym4204
      @udaym4204 ปีที่แล้ว

      @@hamedbahram you are the best sir i hope one day i meet you in person

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว +1

      @@udaym4204 My pleasure.

  • @amitsaini000
    @amitsaini000 ปีที่แล้ว

    good for DRY code

  • @dulonmahadi1837
    @dulonmahadi1837 ปีที่แล้ว +1

    Zoom level is soo low,, please zoom when record, :)

    • @hamedbahram
      @hamedbahram  ปีที่แล้ว

      Sure I'll have that in mind.

  • @imkir4n
    @imkir4n ปีที่แล้ว

    nice