Nested Layouts in NextJs 13 Using Route Groups

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

КОМЕНТАРІ • 74

  • @segu_.
    @segu_. 6 місяців тому +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

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

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

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

      You're welcome! Glad you found it helpful.

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

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

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

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

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

    Great content!

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

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

  • @silicongen
    @silicongen 9 місяців тому

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

    • @hamedbahram
      @hamedbahram  9 місяців тому

      Thanks! Glad it was helpful.

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

    Loved ur videos brother, so easy to understand.

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

      Thanks, I appreciate your comment.

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

    Thank you Hamed , very helpful information

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

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

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

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

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

      You can create different root layout for each route group.

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

    Very good content! Thanks.

  • @rafin_rahman
    @rafin_rahman 8 місяців тому

    nicely explaine!

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

    thanks your for this simple explanation

  • @user-gg3ws2pi7n
    @user-gg3ws2pi7n 8 місяців тому +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  8 місяців тому

      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.

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

    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  2 місяці тому

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

  • @nbo304
    @nbo304 10 місяців тому +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  10 місяців тому

      Try loading the fonts in your root layout.

  • @praneethkumar6506
    @praneethkumar6506 11 місяців тому +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  11 місяців тому +1

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

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

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

    • @hamedbahram
      @hamedbahram  10 місяців тому

      Can you expand on your question...

  • @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 => ua-cam.com/video/wnrGmNDNVvM/v-deo.html

  • @kukiponosanhrvat
    @kukiponosanhrvat 10 місяців тому +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 10 місяців тому

      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  10 місяців тому +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 10 місяців тому +1

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

    • @kukiponosanhrvat
      @kukiponosanhrvat 10 місяців тому

      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​

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

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

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

    Hey bro, can I make Dashboard with this model?

  • @pablom8854
    @pablom8854 9 місяців тому

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

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

      Route groups are for the App router.

  • @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

  • @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.

  • @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.

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

    good for DRY code

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

    nice

  • @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 💯

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

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

    • @hamedbahram
      @hamedbahram  10 місяців тому

      Sure I'll have that in mind.

  • @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.