Next.js Discord

Discord Forum

can we use route groups inside api folder

Unanswered
Southeastern blueberry bee posted this in #help-forum
Open in Discord
Southeastern blueberry beeOP
On the new app router could we use groups inside api segments ? Thank you

6 Replies

@Southeastern blueberry bee On the new app router could we use groups inside api segments ? Thank you
have you tried? i havent tried but i think the answer is very likely yes
Southeastern blueberry beeOP
@joulev Yes thats works but the doc doesnt mention that, so i was thinking if it was a bad practice
in the api folder the separation between pages and api routes isn't so clear anymore, the route resolution is the same way in both places and the only difference is the file name (page.js versus route.js)
so i wouldn't say it's a bad practice; it's working normally
route groups bring minimal benefit but it doesn't bring any drawback either
if you need to separate routes at the same level into different groups, then using route groups to name those groups does make sense