Next.js Discord

Discord Forum

Using prefix "_" for folders in pages directory

Unanswered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Alligator mississippiensisOP
Next 14 |

If I have a folder in my pages directory that starts with underscore, but insidie it i have filed that don't start with underscore, will they be cosidered routes?
pages
_directory
child-directory

6 Replies

I dont remember if pages router has the concept of private folders using underscore. However in app router it makes all subdirectories un-routable.
Cant find anything about page router
@Alligator mississippiensis Next 14 | If I have a folder in my pages directory that starts with underscore, but insidie it i have filed that don't start with underscore, will they be cosidered routes? pages _directory child-directory
Pages router doesn’t have the underscore rule. So yes you will still have /_directory/child-directory.

Put anything that’s not a page (or an api route, or a known special file like _app.js) outside the pages folder.
@Alligator mississippiensis There is no other alternative in the pages folder? thank you!
No afaik. Just put non-route stuff outside the folder