Mastering Next.js Route Handlers: A Comprehensive Guide

Поделиться
HTML-код
  • Опубликовано: 6 янв 2025

Комментарии • 41

  • @judoScott
    @judoScott Месяц назад +1

    This was so helpful. I've really been struggling handlers! Thank you so much. Looking forward to more videos!

    • @coderyan
      @coderyan  29 дней назад

      Happy it helped!

  • @olgalavida7977
    @olgalavida7977 Месяц назад

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

    • @coderyan
      @coderyan  Месяц назад

      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!

  • @david_dhdh
    @david_dhdh Год назад +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👍🏻❤️🐐

  • @testingthingswithbrunocc_io
    @testingthingswithbrunocc_io 8 дней назад

    Great content! I just have a question, is it possible to fetch the api without the domain, like fetch('/api/posts'), if not would it be needed to use domain as an env variable in all environments? Is there a best practice for this?

  • @toko385
    @toko385 7 месяцев назад

    Incredible as always 🔥 Thank You! 🚀

    • @coderyan
      @coderyan  7 месяцев назад

      You’re welcome!

  • @carlotubigon8763
    @carlotubigon8763 11 месяцев назад

    @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  11 месяцев назад +1

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

    • @carlotubigon8763
      @carlotubigon8763 11 месяцев назад

      @@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 11 месяцев назад

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

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

  • @Rotanakkosal
    @Rotanakkosal Год назад

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

    • @joseernestoroldan
      @joseernestoroldan Год назад

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

  • @Elias-xp3bs
    @Elias-xp3bs Год назад +4

    Would be great if this video had timestamps :)

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

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

  • @emmanueldjambatambashe701
    @emmanueldjambatambashe701 5 месяцев назад

    can you give me the resource that you use?

  • @erreyonj
    @erreyonj 4 месяца назад

    Thanks super helpful vid!!

    • @coderyan
      @coderyan  4 месяца назад

      Happy it helps!

  • @amirhalimi-d3d
    @amirhalimi-d3d 3 месяца назад

    🔥🔥🔥🔥

  • @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 9 месяцев назад

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

  • @prashlovessamosa
    @prashlovessamosa Год назад +1

    Thanks

  • @stanleychukwu7424
    @stanleychukwu7424 Год назад

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