I absolutely love your content Nextjs is easily one of the most in demand tech currently and you're providing one of most clear and concise resources for learning it all the way from the basics to the more advanced topics I hope your channel continues to grow, you deserve every success
Hi, thanks for the video. I was trying to use template "server side" but unfortunatly when you navigate with LInk component, the template it seems no refresh some other ""server side" component inside. Why? Thanks for the answer.
The template itself would re-render on every navigation but the server components inside are cached by default. There are different ways to opt your page components into dynamic rendering, but the easiest way is to use the `noStore` function. You can read about it here → nextjs.org/docs/app/api-reference/functions/unstable_noStore
Loving your videos, great content and well explained. Have a question, if you convert the template or the layout into a client component will all the childrens be client components too?
Thank! Glad to hear that. Re your question: only if you import a server component inside a client component will they turn into client components. You can pass server components as children as I did in the video without effecting the server-client boundary. Let me know if that's clear.
so , we should use template to add exit route animations i tried it but it dosen't work what key should i pass to AnimatePresence and Thanks hamed for your amazing content
So what's the purpose of having a layout with a "use client"? Anytime someone wants to use "use client' he can right away use a template instead. And also, why would someone use template without 'use client"? Any case will always use "use client".? I'm a bit confused.
Typically your layout is a server component that gets rendered once and remains the same when user navigates. The template on the hand will re-render every time because it uses a `key` prop. The template doesn't need to be a client component necessarily. I turned it into a client component in this example because I was using framer motion, but you don't need to.
Yeah when I switch screens the mouse hides. I'll have to remember to click on tabs before pointing at different things on the page. Thanks for the feedback.
Not a straight forward way to do that, but you don't need to pass props, just re-fetch your data on the page as well, and React will de-duplicate the request.
@@hamedbahram no, rerender and remount are two different things, they dont have same meaning and they dont do the same thing, remounting it means we remove the component from the browser dom then we mount it back and render (meaning runs component function), it is expensive, rerendering it means rerunning the component function again and rerun all the code inside that function, but the returned components from that components are not removed from the dom and remount back , so it is not expensive compared to remount
@@hamedbahram templates document the use of exit animations but framer motions Animate Presence doesn't work with this because page is not the direct ancestor of the template
@@SanderCokart That's right. I just tested this, and while the exit navigation doesn't run, you can still animate the page. I changed the `main` tag that wraps the page in my template to `motion.main`
I absolutely love your content
Nextjs is easily one of the most in demand tech currently and you're providing one of most clear and concise resources for learning it all the way from the basics to the more advanced topics
I hope your channel continues to grow, you deserve every success
Thanks Kyle! I appreciate your comment, and I'm glad you're finding the videos helpful.
Wonderful lesson thank you. I'm reading throught the NextJS docs now and am so glad you cleared up the difference between layouts and templates.
My pleasure! Glad it was helpful.
Thank you Hamed, This video makes a lot of sense to understand between layout and template.
Glad it was helpful!
Thank you Hamed, It's been nothing but Imppactful and Growth since i subscribed to your channel
My pleasure! Glad to hear that.
Again top notch content on NextJS
Thank you, keep it up 👍🏻
My pleasure!
Thank you so much for your support and teaching, I'm really understanding your explanations.
You are very welcome. Glad to hear that!
Clear and understandable examples. Thank you!
Glad it was helpful!
congratulation for reaching 10k subs well deserving, your content is really great explaing all the bits and pieces of front end development
Thanks! I appreciate it.
congrats bro for the 10K, keep rocking :)
Thank you so much 😀
Thank you Hamed. I appreciate your fantastic tutorial
Anytime Hasan! I'm glad it was helpful.
I thought it just like layout but this video is awesome. Got to know more about template' functionality
Glad it was helpful!
Such a great explanation, Well done Hamed👏
Thank you! 🫡
Best regards from Egypt
Welcome to the channel!
Finally I understood that, thank you! 🙂
Glad it helped!
Nice content. Thanks for explaining concept well
Glad it was helpful!
You are a great instructor!
I appreciate that!
we would love a framer motion video with nextjs
Absolutely! That has been overdue. Will work on it.
Hi, thanks for the video. I was trying to use template "server side" but unfortunatly when you navigate with LInk component, the template it seems no refresh some other ""server side" component inside. Why? Thanks for the answer.
The template itself would re-render on every navigation but the server components inside are cached by default. There are different ways to opt your page components into dynamic rendering, but the easiest way is to use the `noStore` function. You can read about it here → nextjs.org/docs/app/api-reference/functions/unstable_noStore
@@hamedbahram thanks a lot. I will try tomorrow and i will let you know. Sorry I’m learning nextjs framework in theese days. Thanks for your videos.
@@LorenzoSemorile Glad to help!
i have a login page (Auth pages) how can i remove the components in RootLayout in those pages
You can use route groups to create to different layout. Watch this → th-cam.com/video/Go4rL15gYTs/w-d-xo.html
Hi really loved video. By the way what is the font u are using for VS Code editor
Thanks! I'm using Operator mono.
beautifully explained
Thank you! 🙂
clear explanation
Glad to hear that!
Great tutorial ❤
Thanks! Glad you found it helpful.
Loving your videos, great content and well explained. Have a question, if you convert the template or the layout into a client component will all the childrens be client components too?
Thank! Glad to hear that. Re your question: only if you import a server component inside a client component will they turn into client components. You can pass server components as children as I did in the video without effecting the server-client boundary. Let me know if that's clear.
so , we should use template to add exit route animations
i tried it but it dosen't work what key should i pass to AnimatePresence
and Thanks hamed for your amazing content
Yeah that should work, you can use any unique random key or the current path as the key.
This is Gold
Thanks 🫡
Could you u use dark theme in the browser as well? 😊
I'll try it next time 🙂
So what's the purpose of having a layout with a "use client"?
Anytime someone wants to use "use client' he can right away use a template instead.
And also, why would someone use template without 'use client"? Any case will always use "use client".?
I'm a bit confused.
Typically your layout is a server component that gets rendered once and remains the same when user navigates. The template on the hand will re-render every time because it uses a `key` prop. The template doesn't need to be a client component necessarily. I turned it into a client component in this example because I was using framer motion, but you don't need to.
thank you
You're welcome
The mouse pointer in the video is not visible
Yeah when I switch screens the mouse hides. I'll have to remember to click on tabs before pointing at different things on the page. Thanks for the feedback.
Thanks buddy 😊
Any time!
Thanks
Anytime!
how to pass data we fetched in layout to children pages
Not a straight forward way to do that, but you don't need to pass props, just re-fetch your data on the page as well, and React will de-duplicate the request.
you are great teacher ☺️
thanks for all of your efforts
@@AllahomAnsorGaza Thank you! I appreciate that.
Does the template force the component to re-render?
Yes exactly.
But if I want to hide the header for about page?
Then don't put it in that route group.
Thanks, but I found a solution using Route Groups
🇳🇬 Great job
Thanks!
the template is not rerendering, it is remounting completely again
That's what re-rendering means.
@@hamedbahram no, rerender and remount are two different things, they dont have same meaning and they dont do the same thing, remounting it means we remove the component from the browser dom then we mount it back and render (meaning runs component function), it is expensive, rerendering it means rerunning the component function again and rerun all the code inside that function, but the returned components from that components are not removed from the dom and remount back , so it is not expensive compared to remount
your tutorial is excellent but i think content like this can be shorten to at most 10 mins
Thanks for your suggestion.
I hope fixing exit animations on Templates is high on their roadmap, forced to use pages router for page animations
Hmm 🤔 didn't know there is a problem with exit navigation! I'll give it a try. Thanks for sharing.
@@hamedbahram templates document the use of exit animations but framer motions Animate Presence doesn't work with this because page is not the direct ancestor of the template
@@SanderCokart That's right. I just tested this, and while the exit navigation doesn't run, you can still animate the page. I changed the `main` tag that wraps the page in my template to `motion.main`
@@hamedbahram yes only initial and animate. Pages router is required till then.
You are *"Jeff Goldblum"* right? Am I the only one who thinks that?
I'm not that old 😅
not good explanation
Thanks!