Next.js Discord

Discord Forum

Can be created /api folder in Nextjs - App Router?

Unanswered
Whimbrel posted this in #help-forum
Open in Discord
WhimbrelOP
Can be created /api folder in Nextjs - App Router?

20 Replies

Yup, you can do that
WhimbrelOP
@Arinji, not sure why is not working...
You need to make a folder
Its folder routing
The file needs to be route.tsx
And the folder name will be the route name
WhimbrelOP
I have a folder called "api" and a file. I tasted also with route.ts, but still not working.
Try the route.tsx and send the screenshot
WhimbrelOP
Ahh, gotcha
So basically I need to call /api not api/route as it was before (Pages)
Hmm, that's tricky, what about if I want to have some other APIs in /api folder?
Make a folder with the route name
So /api/users is a folder with the name users
WhimbrelOP
ah, gotcha
Make sense, and it's working.
Thank you!! Have a nice evening Γ°ΕΈΛœβ€ž