Next.js 13 API Routes Tutorial

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

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

  • @NativeNotify
    @NativeNotify  Год назад +4

    Next.js 13.2 just came out with a new API routing system in the app directory called API Route Handlers. I made a video about it here: ruclips.net/video/J4pdHM-oG-s/видео.html

  • @LarsRyeJeppesen
    @LarsRyeJeppesen Год назад +5

    Thanks, I was stumbling on the same thing. Just a thing for people: don't implement the actual backend logic in the /pages/api folder. Treat that folder as the backend router, and import calls to the actual implementions from another folder outside of the /pages/api.

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

    You'are a life saver! I even wanted to go back to express because apis just didn't work

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

    Good video! Many people who have covered NextJS updates haven't covered where the API folder stands in the new directory setup. Many people will finds this video useful.

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

    think you my brother, i was very needing it

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

    Great work, makes it easier for me to understand. I did have a problem with query.params[0]. It kept giving me all the values when I was only asking for one. Your example only got you back one params the first time. Thanks for posting this!!!

  • @maskman4821
    @maskman4821 Год назад +2

    This is an excellent Next 13 API routes tutorial, thank you 🙏🙏🙏

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

    "Route Handlers are only available inside the app directory. You do not need to use API Routes (pages) and Route Handlers (app) together, as Route Handlers should be able to handle all use cases." from the nextjs 13 docs. I'm confused

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

      I'll have to check that out. I'm confused now too. When I was reading the documentation they made it sound like you should still use pages for your APIs. Maybe Route Handlers are the app way of doing it. I'll try to make a video about it soon if I figure it out

    • @devyb-cc
      @devyb-cc Год назад +1

      i just stumbled upon vercel video about nextjs 13.2 this day, they are making route handler with route.ts file inside app dir.

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

      @@devyb-cc ​ I'm making a video on the new Route Handlers that will come out early next week. It looks like with 13.2, this is the new way of handling apis

    • @devyb-cc
      @devyb-cc Год назад

      @@NativeNotify it would be great, i might as well subbing. idk tho, if those handler only for edge function or serverless.

    • @devyb-cc
      @devyb-cc Год назад

      @@NativeNotify would be cool if you make those research as well

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

    Ok but I want to return to specific page after post data inside api file, I dont want to show json after send data, then the question is how to redirect to specific page?

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

    Thanks man Great Video Really Helpful

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

    good video only if u have experience with Nextjs. I still don't know how to send a req to api url with my 🔑secret and id unfort

  • @ahliyor.shodiev
    @ahliyor.shodiev Год назад

    Good job!

  • @IvanGarcia-gd5cp
    @IvanGarcia-gd5cp Год назад +1

    thank you very much, I was blocked and in the documentation I could not solve the doubt.

  • @MrAVQ
    @MrAVQ 3 месяца назад

    salve my days I was trying to reach /api out side the pages I nextjs 13.1.6

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

    But i would say this way of building api's is difficult and it makes maintainance hard.

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

    Good video, but you probably dont need to explain switch statements to people trying to learn api routing

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

      When you had to use the pages directory, you had to use switch statements in your API endpoints with Next.js. But since this video, they've come out with app directory API Route Handlers. You no longer have to use switch statements with route handlers. You can learn more in this video: ruclips.net/video/yRJd_tlHu9I/видео.html

  • @0xtz_
    @0xtz_ Год назад +2

    i created a new project today to find this i'm confused 😂
    app
    ├── api
    │ └── hello
    │ └── route.ts
    ├── layout.tsx
    ├── page.module.css
    └── page.tsx

    • @NativeNotify
      @NativeNotify  Год назад +2

      Last week Next came out with a new API Routing system in the app directory. I'm coming out with a video about it Monday or Tuesday.

    • @0xtz_
      @0xtz_ Год назад +1

      @@NativeNotify ook sir 👌🏼

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

      I just made a video about the new Route Handlers in the app directory. You can watch it here: ruclips.net/video/J4pdHM-oG-s/видео.html

    • @0xtz_
      @0xtz_ Год назад

      @@NativeNotify yes I'm watching it, thanks man 👌🏼