Тёмный

Templates vs Layouts in NextJs 13 

Hamed Bahram
Подписаться 162 тыс.
Просмотров 15 тыс.
50% 1

Опубликовано:

 

25 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 91   
@kyle-andrewgovinder9902
@kyle-andrewgovinder9902 11 месяцев назад
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
@hamedbahram
@hamedbahram 11 месяцев назад
Thanks Kyle! I appreciate your comment, and I'm glad you're finding the videos helpful.
@andrew_schaeffer
@andrew_schaeffer 10 месяцев назад
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.
@hamedbahram
@hamedbahram 10 месяцев назад
My pleasure! Glad it was helpful.
@uzairahmed2975
@uzairahmed2975 7 месяцев назад
Thank you Hamed, This video makes a lot of sense to understand between layout and template.
@hamedbahram
@hamedbahram 7 месяцев назад
Glad it was helpful!
@samuelizevbizua
@samuelizevbizua 8 месяцев назад
Thank you Hamed, It's been nothing but Imppactful and Growth since i subscribed to your channel
@hamedbahram
@hamedbahram 8 месяцев назад
My pleasure! Glad to hear that.
@rohitghodeswar11
@rohitghodeswar11 11 месяцев назад
Again top notch content on NextJS Thank you, keep it up 👍🏻
@hamedbahram
@hamedbahram 11 месяцев назад
My pleasure!
@Gangbuster74
@Gangbuster74 11 месяцев назад
congratulation for reaching 10k subs well deserving, your content is really great explaing all the bits and pieces of front end development
@hamedbahram
@hamedbahram 11 месяцев назад
Thanks! I appreciate it.
@devmab
@devmab 11 месяцев назад
Thank you so much for your support and teaching, I'm really understanding your explanations.
@hamedbahram
@hamedbahram 11 месяцев назад
You are very welcome. Glad to hear that!
@eljaz00
@eljaz00 11 месяцев назад
Nice explanation, so if you have similar code in two different pages that share the same parent folder, you can extract that code into a common template and put it in the parent folder. It can also provide a client wrapping mechanism to your nested server pages!
@hamedbahram
@hamedbahram 11 месяцев назад
Yes, exactly! You can accomplish that with both `layout` and `template`. The difference is `layout` doesn't re-render on page navigations whereas `template` does.
@nikhilpsathyanathan
@nikhilpsathyanathan 8 месяцев назад
I thought it just like layout but this video is awesome. Got to know more about template' functionality
@hamedbahram
@hamedbahram 8 месяцев назад
Glad it was helpful!
@tatsumii1420
@tatsumii1420 9 месяцев назад
we would love a framer motion video with nextjs
@hamedbahram
@hamedbahram 9 месяцев назад
Absolutely! That has been overdue. Will work on it.
@albert21994
@albert21994 8 месяцев назад
Clear and understandable examples. Thank you!
@hamedbahram
@hamedbahram 8 месяцев назад
Glad it was helpful!
@fluFFPfizschi
@fluFFPfizschi Месяц назад
Finally I understood that, thank you! 🙂
@hamedbahram
@hamedbahram Месяц назад
Glad it helped!
@hasancheraghi2800
@hasancheraghi2800 11 месяцев назад
Thank you Hamed. I appreciate your fantastic tutorial
@hamedbahram
@hamedbahram 11 месяцев назад
Anytime Hasan! I'm glad it was helpful.
@onyejemeemmanuel94
@onyejemeemmanuel94 Месяц назад
Nice content. Thanks for explaining concept well
@hamedbahram
@hamedbahram Месяц назад
Glad it was helpful!
@afshinkaramifar4429
@afshinkaramifar4429 10 месяцев назад
Such a great explanation, Well done Hamed👏
@hamedbahram
@hamedbahram 10 месяцев назад
Thank you! 🫡
@samislam2746
@samislam2746 10 месяцев назад
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.
@hamedbahram
@hamedbahram 10 месяцев назад
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.
@MohammedIbrahim-fl2sx
@MohammedIbrahim-fl2sx 6 месяцев назад
i have a login page (Auth pages) how can i remove the components in RootLayout in those pages
@hamedbahram
@hamedbahram 6 месяцев назад
You can use route groups to create to different layout. Watch this → ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Go4rL15gYTs.html
@tysondolan1533
@tysondolan1533 Месяц назад
You are a great instructor!
@hamedbahram
@hamedbahram Месяц назад
I appreciate that!
@LorenzoSemorile
@LorenzoSemorile 8 месяцев назад
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.
@hamedbahram
@hamedbahram 8 месяцев назад
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
@LorenzoSemorile
@LorenzoSemorile 8 месяцев назад
@@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.
@hamedbahram
@hamedbahram 8 месяцев назад
@@LorenzoSemorile Glad to help!
@anversadutt
@anversadutt 11 месяцев назад
congrats bro for the 10K, keep rocking :)
@hamedbahram
@hamedbahram 11 месяцев назад
Thank you so much 😀
@AhmedMohamed-q3v4o
@AhmedMohamed-q3v4o 11 месяцев назад
Best regards from Egypt
@hamedbahram
@hamedbahram 11 месяцев назад
Welcome to the channel!
@mahmoudmohamed-xu2lb
@mahmoudmohamed-xu2lb 11 месяцев назад
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
@hamedbahram
@hamedbahram 11 месяцев назад
Yeah that should work, you can use any unique random key or the current path as the key.
@samislam2746
@samislam2746 10 месяцев назад
The mouse pointer in the video is not visible
@hamedbahram
@hamedbahram 10 месяцев назад
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.
@t2e0j0a4
@t2e0j0a4 8 месяцев назад
Hi really loved video. By the way what is the font u are using for VS Code editor
@hamedbahram
@hamedbahram 8 месяцев назад
Thanks! I'm using Operator mono.
@yuensc196
@yuensc196 Месяц назад
clear explanation
@hamedbahram
@hamedbahram Месяц назад
Glad to hear that!
@Felipe-pb9gu
@Felipe-pb9gu 11 месяцев назад
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?
@hamedbahram
@hamedbahram 11 месяцев назад
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.
@CHIRANJIBNANDY1
@CHIRANJIBNANDY1 5 месяцев назад
beautifully explained
@hamedbahram
@hamedbahram 5 месяцев назад
Thank you! 🙂
@RicardoBarbosaSousa
@RicardoBarbosaSousa 11 месяцев назад
Could you u use dark theme in the browser as well? 😊
@hamedbahram
@hamedbahram 11 месяцев назад
I'll try it next time 🙂
@AllahomAnsorGaza
@AllahomAnsorGaza 7 месяцев назад
how to pass data we fetched in layout to children pages
@hamedbahram
@hamedbahram 7 месяцев назад
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.
@AllahomAnsorGaza
@AllahomAnsorGaza 7 месяцев назад
you are great teacher ☺️ thanks for all of your efforts
@hamedbahram
@hamedbahram 7 месяцев назад
@@AllahomAnsorGaza Thank you! I appreciate that.
@moazamdev
@moazamdev 9 месяцев назад
Does the template force the component to re-render?
@hamedbahram
@hamedbahram 9 месяцев назад
Yes exactly.
@arihantjain3274
@arihantjain3274 10 месяцев назад
This is Gold
@hamedbahram
@hamedbahram 10 месяцев назад
Thanks 🫡
@tuRistst
@tuRistst 10 месяцев назад
But if I want to hide the header for about page?
@hamedbahram
@hamedbahram 10 месяцев назад
Then don't put it in that route group.
@tuRistst
@tuRistst 10 месяцев назад
Thanks, but I found a solution using Route Groups
@shahryartavakkoli
@shahryartavakkoli 11 месяцев назад
Thanks
@hamedbahram
@hamedbahram 11 месяцев назад
Anytime!
@maskman4821
@maskman4821 11 месяцев назад
Great tutorial ❤
@hamedbahram
@hamedbahram 11 месяцев назад
Thanks! Glad you found it helpful.
@toone4068
@toone4068 10 месяцев назад
thank you
@hamedbahram
@hamedbahram 10 месяцев назад
You're welcome
@SanderCokart
@SanderCokart 11 месяцев назад
I hope fixing exit animations on Templates is high on their roadmap, forced to use pages router for page animations
@hamedbahram
@hamedbahram 11 месяцев назад
Hmm 🤔 didn't know there is a problem with exit navigation! I'll give it a try. Thanks for sharing.
@SanderCokart
@SanderCokart 11 месяцев назад
@@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
@hamedbahram
@hamedbahram 11 месяцев назад
@@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`
@SanderCokart
@SanderCokart 11 месяцев назад
@@hamedbahram yes only initial and animate. Pages router is required till then.
@raymondmichael4987
@raymondmichael4987 11 месяцев назад
Thanks buddy 😊
@hamedbahram
@hamedbahram 11 месяцев назад
Any time!
@2gbeh
@2gbeh 11 месяцев назад
🇳🇬 Great job
@hamedbahram
@hamedbahram 11 месяцев назад
Thanks!
@namesare4fools
@namesare4fools 10 месяцев назад
your tutorial is excellent but i think content like this can be shorten to at most 10 mins
@hamedbahram
@hamedbahram 10 месяцев назад
Thanks for your suggestion.
@sharpesthawk
@sharpesthawk 9 месяцев назад
You are *"Jeff Goldblum"* right? Am I the only one who thinks that?
@hamedbahram
@hamedbahram 9 месяцев назад
I'm not that old 😅
@deepaksingh-qd7xm
@deepaksingh-qd7xm 5 месяцев назад
not good explanation
@hamedbahram
@hamedbahram 5 месяцев назад
Thanks!
Далее
Nested Layouts in NextJs 13 Using Route Groups
13:33
Просмотров 13 тыс.
10 common mistakes with the Next.js App Router
20:37
Просмотров 214 тыс.
Learn Next.js Parallel Routes In 16 Minutes
16:18
Просмотров 129 тыс.