Templates vs Layouts in NextJs 13

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2024

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

  • @kyle-andrewgovinder9902
    @kyle-andrewgovinder9902 ปีที่แล้ว +2

    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  ปีที่แล้ว

      Thanks Kyle! I appreciate your comment, and I'm glad you're finding the videos helpful.

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

    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  ปีที่แล้ว

      My pleasure! Glad it was helpful.

  • @uzairahmed2975
    @uzairahmed2975 8 หลายเดือนก่อน +1

    Thank you Hamed, This video makes a lot of sense to understand between layout and template.

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

      Glad it was helpful!

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

    Thank you Hamed, It's been nothing but Imppactful and Growth since i subscribed to your channel

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

      My pleasure! Glad to hear that.

  • @rohitghodeswar11
    @rohitghodeswar11 ปีที่แล้ว +3

    Again top notch content on NextJS
    Thank you, keep it up 👍🏻

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

    Thank you so much for your support and teaching, I'm really understanding your explanations.

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

      You are very welcome. Glad to hear that!

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

    Clear and understandable examples. Thank you!

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

      Glad it was helpful!

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

    congratulation for reaching 10k subs well deserving, your content is really great explaing all the bits and pieces of front end development

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

      Thanks! I appreciate it.

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

    congrats bro for the 10K, keep rocking :)

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

      Thank you so much 😀

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

    Thank you Hamed. I appreciate your fantastic tutorial

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

      Anytime Hasan! I'm glad it was helpful.

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

    I thought it just like layout but this video is awesome. Got to know more about template' functionality

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

      Glad it was helpful!

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

    Such a great explanation, Well done Hamed👏

  • @AhmedMohamed-q3v4o
    @AhmedMohamed-q3v4o ปีที่แล้ว +1

    Best regards from Egypt

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

      Welcome to the channel!

  • @any_account-b6x
    @any_account-b6x 2 หลายเดือนก่อน +1

    Finally I understood that, thank you! 🙂

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

      Glad it helped!

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

    Nice content. Thanks for explaining concept well

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

      Glad it was helpful!

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

    You are a great instructor!

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

      I appreciate that!

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

    we would love a framer motion video with nextjs

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

      Absolutely! That has been overdue. Will work on it.

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

    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  9 หลายเดือนก่อน +1

      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 9 หลายเดือนก่อน +1

      @@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  9 หลายเดือนก่อน +1

      @@LorenzoSemorile Glad to help!

  • @MohammedIbrahim-fl2sx
    @MohammedIbrahim-fl2sx 8 หลายเดือนก่อน +1

    i have a login page (Auth pages) how can i remove the components in RootLayout in those pages

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

      You can use route groups to create to different layout. Watch this → th-cam.com/video/Go4rL15gYTs/w-d-xo.html

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

    Hi really loved video. By the way what is the font u are using for VS Code editor

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

      Thanks! I'm using Operator mono.

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

    beautifully explained

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

      Thank you! 🙂

  • @yuensc196
    @yuensc196 2 หลายเดือนก่อน +1

    clear explanation

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

      Glad to hear that!

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

    Great tutorial ❤

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

      Thanks! Glad you found it helpful.

  • @Felipe-pb9gu
    @Felipe-pb9gu ปีที่แล้ว +1

    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  ปีที่แล้ว

      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.

  • @mahmoudmohamed-xu2lb
    @mahmoudmohamed-xu2lb ปีที่แล้ว +1

    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  ปีที่แล้ว

      Yeah that should work, you can use any unique random key or the current path as the key.

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

    This is Gold

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

    Could you u use dark theme in the browser as well? 😊

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

      I'll try it next time 🙂

  • @samislam2746
    @samislam2746 11 หลายเดือนก่อน +1

    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  11 หลายเดือนก่อน +1

      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.

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

    thank you

  • @samislam2746
    @samislam2746 11 หลายเดือนก่อน +1

    The mouse pointer in the video is not visible

    • @hamedbahram
      @hamedbahram  11 หลายเดือนก่อน +1

      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.

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

    Thanks buddy 😊

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

    Thanks

  • @AllahomAnsorGaza
    @AllahomAnsorGaza 8 หลายเดือนก่อน +1

    how to pass data we fetched in layout to children pages

    • @hamedbahram
      @hamedbahram  8 หลายเดือนก่อน +1

      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 8 หลายเดือนก่อน +1

      you are great teacher ☺️
      thanks for all of your efforts

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

      @@AllahomAnsorGaza Thank you! I appreciate that.

  • @moazamdev
    @moazamdev 11 หลายเดือนก่อน

    Does the template force the component to re-render?

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

      Yes exactly.

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

    But if I want to hide the header for about page?

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

      Then don't put it in that route group.

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

      Thanks, but I found a solution using Route Groups

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

    🇳🇬 Great job

  • @hamidhamri5384
    @hamidhamri5384 29 วันที่ผ่านมา

    the template is not rerendering, it is remounting completely again

    • @hamedbahram
      @hamedbahram  28 วันที่ผ่านมา +1

      That's what re-rendering means.

    • @hamidhamri5384
      @hamidhamri5384 25 วันที่ผ่านมา

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

  • @namesare4fools
    @namesare4fools 11 หลายเดือนก่อน

    your tutorial is excellent but i think content like this can be shorten to at most 10 mins

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

      Thanks for your suggestion.

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

    I hope fixing exit animations on Templates is high on their roadmap, forced to use pages router for page animations

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

      Hmm 🤔 didn't know there is a problem with exit navigation! I'll give it a try. Thanks for sharing.

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

      @@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  ปีที่แล้ว

      @@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 ปีที่แล้ว

      @@hamedbahram yes only initial and animate. Pages router is required till then.

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

    You are *"Jeff Goldblum"* right? Am I the only one who thinks that?

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

      I'm not that old 😅

  • @deepaksingh-qd7xm
    @deepaksingh-qd7xm 7 หลายเดือนก่อน

    not good explanation