Lesson 66 of 81
Most files you put inside a route folder are never at risk of becoming a route at all — the router only ever looks for a handful of exact names. Knowing that changes how confidently you colocate.
11 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
This topic is about judgment and practical tradeoffs more than a single right answer — a mock interview is the better way to test yourself on it.
Be interviewed on this →Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
A reasonable first instinct coming into the App Router is caution: "if app/dashboard/ is a URL segment, is it safe to put a test file or a stylesheet in there too?" The answer is yes, by default, for a reason worth actually understanding rather than just trusting: the router isn't scanning a folder for "anything that looks like a component" and deciding what to do with it. It's checking for a short, exact list of reserved filenames — page, layout, loading, error, route, and a few others. A file named anything else, in any route folder, at any nesting depth, is structurally invisible to the router. Card.tsx, Card.test.tsx, Card.module.css, and useCardData.ts sitting right next to page.tsx don't need any special treatment to stay non-routable — they already are, just by not matching a reserved name.
So what is the underscore-prefixed private folder convention actually for, if plain colocation is already safe? It's a second, stronger layer for the narrower case where a folder, not just a file, needs to be guaranteed non-routable even if something reserved ends up nested inside it later. A _components/ folder that someone later drops a stray page.tsx into (a copy-pasted example, a generated file from a design tool export, an accidental rename) stays completely excluded from routing — underscore-prefixing isn't protecting the files you can see today, it's protecting against a reserved filename showing up inside that folder by accident, at any depth, without anyone changing the folder's own name.
app/dashboard/
├── page.tsx → the route
├── RevenueChart.tsx → plain colocation — never a route, no underscore needed
├── RevenueChart.test.tsx → same
├── RevenueChart.module.css → same
├── useRevenueData.ts → same
└── _fixtures/
└── mock-data.json → private folder — an extra guarantee nothing nested here routes
RevenueChart.tsx next to page.tsx works today for the same reason a typo'd Page.tsx (capital P) silently fails to become a route in the file-conventions lesson: the match is exact-string, not "looks like a component." _fixtures/ doesn't need that protection for the one mock-data.json file currently inside it — it's there so that whatever gets added to that folder next year, by someone who's never read this convention, still can't accidentally surface as a route.
_fixtures/nested/deeper/page.tsx is just as unreachable as _fixtures/page.tsx — the underscore on the top folder covers everything below it, no matter how many levels down..test.tsx or .module.css suffix carries no special meaning to the App Router at all. Those conventions exist for other tools (your test runner, your bundler's CSS Modules handling) — the router doesn't know or care about them; it's simply not looking for those names in the first place.app/ entirely (into a top-level components/ or lib/) is a separate, legitimate strategy — colocation inside a route folder is for things genuinely specific to that one route, not a replacement for a shared component library."Is it safe to put a Storybook story file or a Jest test right next to page.tsx in the same folder?" tests whether a candidate understands why the App Router's file conventions are safe to colocate around — "yes, because the router only matches a short exact list of reserved names" is a meaningfully stronger answer than "yes, I've just never seen it break," because it also correctly predicts the one case where it's worth reaching for a private folder instead of trusting plain colocation.