❇ READ THIS BEFORE/AFTER COMPLETING THIS VIDEO ❇ In the 100+ comments below, there are some common questions. I thought of answering them ahead and pinned it here so that, you do not have to ask the same again(in case) 😊 - As Next.js is been evolving, it has some breaking changes version over version. This video was made with the version 14.1.4, where having the HTML and body tag in one of the root layouts was enough. But with the latest upgrade(tested with v14.2.17), it is mandatory to add the to all root layouts. Else, you will get the "Missing Root Layout tags" error. In future upgrade, there might be something else! We will see that then and update again. For now, the changes have been incorporated into the GitHub Repo that I used in this video: github.com/tapascript/nextjs-multiple-root-layout. Cheers! - Multiple root layout will cause the full page load as opposed to a client-side navigation. This is the expected behaviour and mentioned in the Next.js official doc as well: "Navigating across multiple root layouts will cause a full page load (as opposed to a client-side navigation). For example, navigating from /cart that uses app/(shop)/layout.js to /blog that uses app/(marketing)/layout.js will cause a full page load. This only applies to multiple root layouts." That's all for now. As a teacher, It's my responsibility to provide you all required information and add value to your journey. Keep learning. ❤
@kenkioqqo9 ай бұрын
Absolutely awesome! You started by describing the exact mistake I was making while trying to create a different layout for my dashboard, and then you provided a wonderful solution that works like a charm. I can't thank you enough for this tutorial.
@tapasadhikary9 ай бұрын
Thanks! I'm so glad that it helped you ❤️
@joshuaoluwapamilerinonifad22048 ай бұрын
funny how it's dashboard that brought me here too😅
@thebenkalungi7 ай бұрын
Thanks for the clarity... Been facing this route problem since yesterday and almost gave up but your video has saved me.
@tapasadhikary7 ай бұрын
Thank you ❤️
@klebergermano33564 ай бұрын
I was racking my brains over this, thanks a lot for the clear explanation, really helpful
@tapasadhikary4 ай бұрын
Thanks a lot.
@jahangirkhan374710 ай бұрын
Ur way of explaining the concept is awesome sir ❤❤❤
@tapasadhikary10 ай бұрын
Thanks a lot, keep learning 👍
@snow-script10 ай бұрын
Your every video is going outstanding many different things but I think just for a recap of the last moment. 💕💕
@metadope94075 ай бұрын
Thanks Tapas da...you always shows all the edge cases...you're an awesome teacher❤
@tapasadhikary5 ай бұрын
Thanks a lot.
@mateomohr34156 ай бұрын
FINALLY I FOUND THE VIDEO TO SOLVE MY PROBLEM, TY TAPAS. THE EXPLANATION COULDNT BE ANY BETTER
@tapasadhikary6 ай бұрын
You are most welcome.. I am so glad that my video helped you... super happy ❤
@prateekshawebdesign83776 ай бұрын
Great video! Your explanation of multiple layouts in Next.js was clear and practical. The examples were easy to follow and very helpful.
@tapasadhikary6 ай бұрын
@@prateekshawebdesign8377 So glad to hear that ✨🔥
@sovanchheang1702 ай бұрын
Amazingly clear, easy to learn and follow you, Sir. I really appreciate for your great teaching.
@tapasadhikary2 ай бұрын
@@sovanchheang170 great 👍 thanks
@ZeynalZeynalli-yo2nl5 ай бұрын
you are life saver sir. awesome video for those who dont want to read the docs.
@tapasadhikary5 ай бұрын
Thank you!
@AlexanderWilson-ht5dt5 ай бұрын
Great explanation on Next.js route grouping! Astro.js has a very similar approach, and it's really helpful to see how both frameworks handle this. This video was super helpful in deepening my understanding-thanks for sharing!
@tapasadhikary5 ай бұрын
@@AlexanderWilson-ht5dt most welcome ✨
@wasiuddinmansoori33857 ай бұрын
The way you explained is very insane and informative. Sooo much informative content. ♥
@tapasadhikary7 ай бұрын
❤️❤️❤️
@froilanimnida6 ай бұрын
straightforward video, does the thing i wanted to know. thanks!
@tapasadhikary6 ай бұрын
Awesome 👍
@AngelaCui-fn2tn5 ай бұрын
Thank you so much for sharing your knowledge!
@tapasadhikary5 ай бұрын
@@AngelaCui-fn2tn welcome
@DCBlogdev2 ай бұрын
Thank you, exactly what I needed.
@tapasadhikary2 ай бұрын
@@DCBlogdev cool
@Learexx5 ай бұрын
I really needed this, thank you sir
@tapasadhikary5 ай бұрын
@@Learexx great, thanks!
@hanyehyaghoubi87492 ай бұрын
Thank you very much. You saved me from a big challenge
you just got a new subscriber sir.. you are a genius
@tapasadhikary8 ай бұрын
Thanks, man. It means a lot ❤️
@taldr275 ай бұрын
Thank you man!
@tapasadhikary5 ай бұрын
Welcome 😊
@DavidCarr-r6s2 ай бұрын
thank you, explained very well ;)
@tapasadhikaryАй бұрын
Glad you liked it!
@ederross8 ай бұрын
AMAZING! PERFECT! THANKS A LOT FROM THE BOTTOM OF MY HEART!
@tapasadhikary8 ай бұрын
Wow… thanks a lot ❤️. Don't forget to subscribe 😉, much more coming!
@Elvis-is-king-l3s22 күн бұрын
Amazing! Thank you!
@tapasadhikary22 күн бұрын
@@Elvis-is-king-l3s Cool, thanks ❤️
@treasurechest22422 ай бұрын
Thank you. I had an issue with the parent layout still being applied in the child layout.
@MailsonVarela-on7we8 ай бұрын
saved my day! thanks for the explaination
@tapasadhikary8 ай бұрын
Thanks mate, for letting me know. You are most welcome.
@ghimirerahul394 ай бұрын
thanks bro for this awesome video and awesome explaination
@tapasadhikary4 ай бұрын
@@ghimirerahul39 Thanks a lot 👍
@magehdinc6 ай бұрын
Brilliant Tutorial!
@tapasadhikary6 ай бұрын
Thanks a lot ❤️
@jspies2020Ай бұрын
you're the man!!
@tapasadhikaryАй бұрын
Thank you!
@Crazysocity2 ай бұрын
Think i have a web page there are home,about,program,contact and first 3 page had header and footer but on contact page i don't want header footer.In this case should i carete layout for all, Or just create a layout for contact page?Hope your kindly reply.😊😊😊😊
@kaioneal61608 ай бұрын
Finally Thank you 🙏
@tapasadhikary8 ай бұрын
Most welcome
@java4278 ай бұрын
Awesome video! Thanks
@tapasadhikary8 ай бұрын
Glad you liked it!
@boot-comp6 ай бұрын
perfect explanation thaanks
@tapasadhikary2 ай бұрын
cool
@md.mojnumiah10 ай бұрын
thanks for sharing, vai.
@tapasadhikary10 ай бұрын
Welcome ❤️
@guvenfazli3 ай бұрын
Thank you sir.
@javascriptprograming98282 ай бұрын
what about dashboard layout, if i do not want to need root layout header and footer in dashboard layout. that time how to handle this bro?
@ilyahuman75659 ай бұрын
Hi there! ChatGPT tells me that it is not required to put html and body tags into RootLayout, cause since Next.js13 it is automatically. But I cannot see this in next doc. Any ideas?)
@tapasadhikary9 ай бұрын
Me neither. Your web document needs the root HTML to render and to do many other things including the locale support.. So there must be at least one root layout where the HTML tag should be there.. Not sure about the chatGPT suggestion, though...
@Daniel-Y724 ай бұрын
Do I have to add html & body tag to other layouts as well? Because if I don't, it gives the `Missing Root Layout Tags` error.
@tapasadhikary4 ай бұрын
@@Daniel-Y72 no not needed..for that error seem to be the issue with the layout hierarchy
@wforbes873 ай бұрын
today's nextjs version '14.2.13' gives this error modal pop-up. while the version that this video was created with (14.1.2) does not. clone his repo and see the difference
@langchats2 ай бұрын
There have another issue, after using route group, when we are trying to navigate then the page is re-loading like a normal html and then loading another page. but we expect navigation behavior without any refresh. can you please tell me how we can fix it?
@tapasadhikary2 ай бұрын
This is how Next.js works! We can not do much about it. The below text is from their documentation: "Navigating across multiple root layouts will cause a full page load (as opposed to a client-side navigation). For example, navigating from /cart that uses app/(shop)/layout.js to /blog that uses app/(marketing)/layout.js will cause a full page load. This only applies to multiple root layouts.". I hope it makes sense now. Thanks for watching my videos and learning from tapaScript. Cheers!
@joaoarthurbandeira5 ай бұрын
Great video! Question: could i leave a layout.tsx file in the root level only wrapping the children with html, body and say GoogleTagManager tags while also having, at the same time, layout.tsx files for each route grouping, so i dont have to put these tags on each of them? In this case, would this root level layout.tsx file wrap all of the other layouts with these tags and work? Thanks!
@joaoarthurbandeira5 ай бұрын
I tested here and it still worked and also it also stopped the whole page from getting reloaded when navigating between these route groups, i guess because now they share the same html tag. Does this make sense or am i missing something and should not do this?
@tapasadhikary5 ай бұрын
Yes it will work… do not repeat the html and body in child layouts.
@joaoarthurbandeira5 ай бұрын
@@tapasadhikary Thanks! Is this approach better since it has the same benefits but it doesnt force reload when navigating between these route groups or does it have any cons?
@tapasadhikary5 ай бұрын
@joaoarthurbandeira yep great approach
@aburaihan-py4vi10 ай бұрын
Excellent!!!!!!
@tapasadhikary10 ай бұрын
Thank you ❤️
@nahid_ulkabir82408 ай бұрын
I canot use any react hook like useState inside /marketing page . not event a console is working on that page . please help me , I want a client component on that page
@tapasadhikary8 ай бұрын
It is because the marketing page is a server component and you can not use the client side things like React Hooks in the server component. The design pattern you must follow is, take out the client interaction part separately in a separate client component where you can use all the hooks and make sure to use the "use directive" for client component. After that import the client component to the marketing page server component... It is important to understand how you should compose your server and client components for a better results including the SEO of the app. I hope it helps.
@nahid_ulkabir82408 ай бұрын
@@tapasadhikary thank you very much
@DuK-21026 ай бұрын
This solved my problem but there is 1 more issue occured. How do you make a not-found page for this multiple root layouts? Even if I put not-found.tsx file in both (auth) and (home) folder, when go to wrong url, the browser render not found page from default nextJS itself not from my not-found.tsx file.
@tapasadhikary6 ай бұрын
Thank you! Let me cover not found and error in a video
@codeWithSleek3 ай бұрын
Thank you!
@VivekSpecscart9 ай бұрын
Hi sir, i have get error when I create (home) folder and move "app/layout.tsx" and ''app/page.tsx' files in the folder, can you please check? How can I connect with you? please help 🙏
@imdefnotash6 ай бұрын
UFF thank god you helped me!
@tapasadhikary6 ай бұрын
Glad I could help!
@naufui3 ай бұрын
Thank you so much!
@aroshasandaruwan36674 ай бұрын
clearly explained.
@tapasadhikary2 ай бұрын
Thanks
@saimundev8 ай бұрын
when I declare a route link with href the page is reloaded.. how to solve this??
@tapasadhikary8 ай бұрын
What’s the href value?
@itsearcast3 ай бұрын
@@tapasadhikary lets take an example---"(home) (dashboard) when I am navigating from dashboard to home using the navigation is working correctly but it is causing the page reload
@nelsonkc47033 ай бұрын
but in local it is shwoing gittering issue when i switch between layout thought somehow that layout shares most of same content .but this issue is not in live
@tapasadhikary3 ай бұрын
That’s weird.
@MrTingle-qi2ne6 ай бұрын
My trouble is not knowing how to achieve route grouping but with dynamic slugs ( [...slug] ), because obviously this confuses the system. I've tried everything but still can't figure out how to get the Root Layout to distinguish between header/noheader based on CMS data. I can do it by putting headers inside sub-layouts instead (as sub layouts can receive the slug array) but that unfortunately re-renders the header every time the route changes (problematic for preserving header state). I don't actually think there is a clean solution to this beyond designating a hardcoded no-header sub route. Anyway... easy enough for me to manually make per-project specific folders in src/app to manage this, but I was dreaming up a pure CMS driven solution :(.
@SyedSINA7 ай бұрын
Thanks for the solution, There is still one little problem that the whole page gets reloaded when navigating between these route groups. For example, when a user navigates between HomeLayout routes and MarketingLayout routes whole page gets reloaded. How can I stop reloading whole page and only redirect on client side?
@tapasadhikary7 ай бұрын
Where do you see the reload? In the example project I shared with the video? Or in your project?
@SyedSINA7 ай бұрын
@@tapasadhikary In my project, I have two route groups that has separate layouts. When I navigating between routes of these two layouts the full page reload happens. This is mentioned in the Next.js docs too. But I didn't find an elegant solution to do it without full page reload
@tapasadhikary7 ай бұрын
@@SyedSINA got it. Yes, this happens. Do you have a main root layout apart from these parallel route layouts?
@SyedSINA7 ай бұрын
@@tapasadhikary No, there is no main root layout in the root folder. I followed the structure exactly like in the video. In my project, it looks like this: (booking) -> booking -> [layout.tsx, page.tsx] (default) -> [layout.tsx, page.tsx] When navigating from '/' to '/booking', a full reload happens. I am aware that the Next.js documentation mentions this issue, but it would be better to have something like the getLayout method from Next.js 12 in this version as well.
@mostafizurrahman43406 ай бұрын
@@SyedSINABro did you manage to solve this problem.
@mdsumonh.shohan91594 ай бұрын
tapash vai in my code on marketing route does not run without html and body tags in marketing RootLayout.
@tapasadhikary2 ай бұрын
I shall test it with the latest version and let you know,
@YashKadam-k5q9 ай бұрын
Hot reloading is only working for the (home) group and not for other groups. Additionally, I have react-hook-form implemented in other groups, and the same issue occurs: it's only working in the (home) group and not in other groups.
@tapasadhikary9 ай бұрын
Try removing the .next folder and restart the local server.
@sarangsami65979 ай бұрын
you saved my life
@tapasadhikary9 ай бұрын
Glad I could help ❤️
@MichaelMonteroJimenezАй бұрын
Amazing!
@tapasadhikaryАй бұрын
@@MichaelMonteroJimenez thanks a lot
@najmulislam3448 ай бұрын
very very helpful
@tapasadhikary8 ай бұрын
Thank you ❤️
@muhammadinaammunir67616 ай бұрын
Good content
@tapasadhikary6 ай бұрын
@@muhammadinaammunir6761 thanks a lot ❤️
@dhananjaygupta85544 ай бұрын
Thanks ❤
@tapasadhikary4 ай бұрын
Welcome ❤️
@thinkwithroyofficial4 ай бұрын
use this method why global.css not applicable for child component pages ?
@tapasadhikary2 ай бұрын
We can do that too
@davittchike4 ай бұрын
im stuck both of the layouts get rendered pls help
@tapasadhikary2 ай бұрын
Chekout the code repo gave in the description and refer plz.
@dongripavankumar9342Ай бұрын
good explanation
@tapasadhikaryАй бұрын
Awesome, glad you liked it 👍
@ItsKrishnaPanthi7 ай бұрын
Need to add html and body tag to the marketing route layout as well, other wise browser error pops up saying tags missing in the Root Layout.
@tapasadhikary7 ай бұрын
Do you get it as an Hydration error?
@ItsKrishnaPanthi7 ай бұрын
@@tapasadhikary It's not an hydration error. Nextjs docs says html and body tags need to be added to each root layout. Maybe some kind of latest requirement.
@tapasadhikary7 ай бұрын
@@ItsKrishnaPanthi Got it, thanks!
@samshan8137 ай бұрын
Thanks for the video ,, but there is error comes on jsconfig.json, could you please advise
@tapasadhikary7 ай бұрын
What error? Also have you restarted VS code and saw if the error still there?
@AlexRankin-gi1tl8 ай бұрын
Life saver!
@tapasadhikary8 ай бұрын
So glad, Alex that it helped you! Thanks.
@iqbalrahmatullah70882 ай бұрын
Thanks sir your video give me solution
@tapasadhikary2 ай бұрын
@@iqbalrahmatullah7088 super
@ericsiddiq763410 ай бұрын
nice tricks!
@tapasadhikary10 ай бұрын
Thank you 🙏
@JunedAhmad3132 ай бұрын
thanks sir for this video
@tapasadhikary2 ай бұрын
Welcome
@clearface12310 ай бұрын
does this mean we have to duplicate the providers across every layout
@tapasadhikary10 ай бұрын
Nope, you can providers common and reuse across the layouts.
@Anguraj9210 ай бұрын
Nice sir
@tapasadhikary10 ай бұрын
Thanks, brother.
@smselva93245 ай бұрын
How to handle redux setup with multiple layouts Sir
@tapasadhikary5 ай бұрын
You should do it at the client side.
@zaheerabbas83442 ай бұрын
v nice
@MiteshBhagwant2 ай бұрын
thanks sir
@tapasadhikaryАй бұрын
Great. Let me know if you have any question.
@DeveloperJunaid8 ай бұрын
Zabardast
@tapasadhikary8 ай бұрын
Thanks vai, appreciate it.
@EverydayBeing-de1qu8 ай бұрын
Thank you
@tapasadhikary8 ай бұрын
Most welcome 🔥
@ChickenChaap7 ай бұрын
love it
@tapasadhikary7 ай бұрын
So glad
@pspremshakti10837 ай бұрын
But in this technique the page is reloading
@tapasadhikary2 ай бұрын
This is how Next.js works! We can not do much about it. The below text is from their documentation: "Navigating across multiple root layouts will cause a full page load (as opposed to a client-side navigation). For example, navigating from /cart that uses app/(shop)/layout.js to /blog that uses app/(marketing)/layout.js will cause a full page load. This only applies to multiple root layouts.". I hope it makes sense now. Thanks for watching my videos and learning from tapaScript. Cheers!
@omarrayes22819 ай бұрын
is this the only solution ? for doing that ? please if there something else give a link to read . And Thanx
@tapasadhikary9 ай бұрын
This is what I found as one solution… the other solution is to get the pathname from route and based on path name you show hide things. For that you have to make the components client components forcefully.
@HasanAhmedNews3 ай бұрын
thankyou Tapas Vai
@tapasadhikary3 ай бұрын
Welcome
@rustan-e33 ай бұрын
But the app root need to have a layout?
@tapasadhikary2 ай бұрын
Nope.
@deepakbind67745 ай бұрын
and what about not-found page
@tapasadhikary5 ай бұрын
It is simple. Include a not-found.tsx or not-found.jsx file along with the layoout.jsx or layout.tsx file for each layouts. Whenever a notFound() exception is throws from the route the respective not-found page would be taking care of it.
@joaopaulosantana81510 ай бұрын
🚀🚀🚀🚀
@tapasadhikary10 ай бұрын
😍😍
@darkx69167 ай бұрын
Legend Tapas 🗿
@tapasadhikary7 ай бұрын
🙏 🙏
@hiteshemsammz94122 күн бұрын
Thanks
@tapasadhikary22 күн бұрын
@@hiteshemsammz941 ❤️❤️
@yasineNextjs5 күн бұрын
tnx
@tapasadhikary10 сағат бұрын
Glad you liked it!
@MohsanRaza-hr1gi2 ай бұрын
thanks
@arifulhaque323610 ай бұрын
❤❤
@tapasadhikary10 ай бұрын
❤️❤️
@evgeny99454 ай бұрын
best
@tapasadhikary4 ай бұрын
@@evgeny9945 thanks!
@igorr46827 ай бұрын
and you forgot to mention that if you do this, this will do full pager render if you go from one layout to the other
@tapasadhikary7 ай бұрын
Yep that happens, true. Mentioned in doc too… good point.
@abujayed-dot-com9 ай бұрын
Sir, You have no idea what level of video is it. sub.
@tapasadhikary9 ай бұрын
Glad you liked it… keep learning 🫶
@Abhishekbhat-p6d9 ай бұрын
Solved many problems especially in authenticated and not authenticated route
@tapasadhikary9 ай бұрын
Great, glad to know ❤️
@იოსებივარდოშვილი9 ай бұрын
gg
@fadhil40085 күн бұрын
Yeah this is why I think nextjs sucks, trying to make things easy by making providing miltiple layout feature but ended up giving so muh headaches to developers
@tapasadhikary3 күн бұрын
Yeah but its kind of one time… once you fix it in the beginning..,should be set
@SabarangChakma10 ай бұрын
বাংলায় কোর্স চাই.... ইংরেজি সবার বোধগম্য নয়
@tapasadhikary10 ай бұрын
কি বলি বলুন তো ভাই। আমি আপনার সাথে already সহমত। tapaScript বাংলা চ্যানেলের promotion ও শুরু হয়ে গেছে, আর সেটা এসেও যাবে আর ১-২ সপ্তাহে। কিন্তু তবুও আমি আনুরধ করবো ইংরেজি ভিডিও দেখে আসতে আসতে শেখার। দুটোই চলুক। আপনি বাংলাতে শিখবেন, ইংরাজিতেও শিখবেন। অসুবিধা হলে জিজ্ঞাসা করে নেবেন... হেল্প করবো। আশা করি আপনি আমার দুটো চ্যানেলকেই সাপোর্ট করবেন। 😀😍