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
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.
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.
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!!!
"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
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 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
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?
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
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
so this 13.1 method is now outdated?
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.
You'are a life saver! I even wanted to go back to express because apis just didn't work
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.
Thank you!
think you my brother, i was very needing it
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!!!
This is an excellent Next 13 API routes tutorial, thank you 🙏🙏🙏
You're welcome!
"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
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
i just stumbled upon vercel video about nextjs 13.2 this day, they are making route handler with route.ts file inside app dir.
@@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
@@NativeNotify it would be great, i might as well subbing. idk tho, if those handler only for edge function or serverless.
@@NativeNotify would be cool if you make those research as well
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?
Thanks man Great Video Really Helpful
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
Good job!
thank you very much, I was blocked and in the documentation I could not solve the doubt.
salve my days I was trying to reach /api out side the pages I nextjs 13.1.6
But i would say this way of building api's is difficult and it makes maintainance hard.
Good video, but you probably dont need to explain switch statements to people trying to learn api routing
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
i created a new project today to find this i'm confused 😂
app
├── api
│ └── hello
│ └── route.ts
├── layout.tsx
├── page.module.css
└── page.tsx
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.
@@NativeNotify ook sir 👌🏼
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
@@NativeNotify yes I'm watching it, thanks man 👌🏼