next13 app dir - multiple route handlers in one folder?
Is it possible to have multiple route handlers in the app/api dir in the same folder? It seems like it would get out of control pretty fast if you need to create a folder for each route…
Compared to trpc for example where you could have multiple routes under a common path.
You can do so with appDir route handlers but you’d have so many more folders and files… is this the only way or can you avoid all these folders for each route?
4 Replies
That is… each folder has it’s own route.ts file to denote a separate route. As opposed to smth like… doThis.route.ts and doThat.route.ts all in one folder
welcome to next.js 13, where every little thing needs its own folder and 5 files
For pages I personally like that structure as it’s quite organized. For routes… my initial thought is to want to put a few on one page like many other frameworks allow for…
the solution is to use trpc in next 13 lol
the way they implemented file routing for /api AGAIN is rough