Mastering Next.js Route Handlers: A Comprehensive Guide

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

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

  • @olgalavida7977
    @olgalavida7977 12 วันที่ผ่านมา

    Subscribed within first 5 minutes. Exactly what i was looking for. Api routes for dummies! Thank you

    • @coderyan
      @coderyan  12 วันที่ผ่านมา

      Happy it helped!

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

    I love the way you explained the route handlers. I’ve watched many videos trying to explain what you did in 30+ minutes. I fully understand the process now. Thanks!

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

      Happy to hear it helped!

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

    Thanks for all your videos! I started my first Next commercial project, thinking something like "I know React and CRA, so let's go for it". I quickly got stuck on APIs, and discovered your channel thanks to this video. I put the project on standby while I watched your entire playlist, which was very well explained in a simple way.

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

      You’re welcome! Happy to hear the videos are helping and best of luck on your project!

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

    I've been waiting so long for this video and my guy just uploaded, great job👍🏻❤️🐐

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

      Thank you!

  • @toko385
    @toko385 6 หลายเดือนก่อน

    Incredible as always 🔥 Thank You! 🚀

    • @coderyan
      @coderyan  6 หลายเดือนก่อน

      You’re welcome!

  • @Elias-xp3bs
    @Elias-xp3bs ปีที่แล้ว +4

    Would be great if this video had timestamps :)

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

    a really useful guide, thanks
    it would be better if you uploaded the final code to the git repo so that it can be quickly re-read without reviewing the video

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

      Thank you and I appreciate the feedback. In future videos, I'm better about pushing the final code up to Github

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

    Thanks super helpful vid!!

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

      Happy it helps!

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

    nicely explained. Even to me it made all sense. Just one question. Isn't it better to have the components directory outside of the app router ? since if we have it inside we would effectively create new routes ending up with localhost:3000/components/ or doesn't it make a difference as long as we don't define a route or page file ?

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

      Thank you! And it doesn’t actually matter. The only time a folder becomes public is when you add a route.js or page.js file within the folder

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

      @@coderyan I see thanks, now I learned even more!

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

      @SuperYoda7 happy to hear it!

  • @amirhalimi-d3d
    @amirhalimi-d3d 2 หลายเดือนก่อน

    🔥🔥🔥🔥

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

    Thanks for detailed explanation. but I have one confusion, what is the need of route handler when we can do the same thing from server components and client components.

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

      Great question. And most of the time, you shouldn’t need to use a route handler. But there are situations where they’re useful. For example, if you update your database in a client component and want to revalidate the cache, you make make an API request to a route handler to revalidate the cache for a certain path

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

    @Code Ryan Why is it needed to fetch it from route handlers first 24:04 before fetching it in posts page? Is it not possible to fetch it directly in posts page without the route handler?

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

      Yeah that’s probably fine. But this video is covering route handlers so just showing how they work

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

      @@coderyan I see, I just want to know when to use the route handlers and when to use in-page fetch. There may be some advantages/disadvantages between the two. Do you know any?

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

    whats the purpose of using useRouter instead of redirect(21:34) on the view post button? Whats the difference? can anyone explain?

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

    can you give me the resource that you use?

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

    thank you boss! hi beautiful dog, you about to go for a walk!

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

      Haha thank you!

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

    I have an question? Since we can get data with fetch method, so why we need route hander ?

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

      to create endpoints so you can create your own resources api.

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

    Thanks

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

      You're welcome

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

    still don't understand the logic for not allow to create route.ts at the same route segment

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

      I’m not entirely sure I understand what you mean, could you maybe rephrase your question?

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

      @@coderyan Nextjs uses the convention of page.tsx to serve a route, so the same way route handler has a convention of route.ts , page.tsx and route.ts can co-exist on the same level, But Nextjs does not allow at the same level.

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

      @@mohanram18 Yep, you're going to have to nest the route.ts in ./api/ or /app/api/...