Templates vs Layouts in NextJs 13

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 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.

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

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

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

      My pleasure! Glad to hear that.

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

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

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

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

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

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

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

      Glad it was helpful!

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

    congrats bro for the 10K, keep rocking :)

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

      Thank you so much 😀

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

      @@LorenzoSemorile Glad to help!

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

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

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

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

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

    Clear and understandable examples. Thank you!

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

      Glad it was helpful!

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

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

    Such a great explanation, Well done Hamed👏

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

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

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

      Glad it was helpful!

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

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

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

    Thank you Hamed. I appreciate your fantastic tutorial

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

      Anytime Hasan! I'm glad it was helpful.

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

    The mouse pointer in the video is not visible

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

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

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

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

      Thanks! I'm using Operator mono.

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

    how to pass data we fetched in layout to children pages

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

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

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

      @@AllahomAnsorGaza Thank you! I appreciate that.

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

    Nice content. Thanks for explaining concept well

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

      Glad it was helpful!

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

    Best regards from Egypt

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

      Welcome to the channel!

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

    we would love a framer motion video with nextjs

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

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

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

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

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

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

      I'll try it next time 🙂

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

    Does the template force the component to re-render?

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

    You are a great instructor!

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

      I appreciate that!

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

    Finally I understood that, thank you! 🙂

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

      Glad it helped!

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

    Great tutorial ❤

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

      Thanks! Glad you found it helpful.

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

    beautifully explained

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

      Thank you! 🙂

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

    clear explanation

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

      Glad to hear that!

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

    the template is not rerendering, it is remounting completely again

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

      That's what re-rendering means.

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

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

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

    This is Gold

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

    Thanks buddy 😊

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

    thank you

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

    Thanks

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

    🇳🇬 Great job

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

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

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

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

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

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

      I'm not that old 😅

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

    not good explanation