What do route groups and underscore-prefixed folders do?
Take a moment.
Say your answer out loud or write it down first — retrieval is what makes it stick. Reveal when you're ready.
Short answer
(group) folders organize routes without affecting the URL — useful for different layout shells sharing a path space. Underscore prefixes mark private folders excluded from routing: _components, _lib keep colocation tidy.
Detailed explanation
Route groups wrap related routes in parentheses: app/(marketing)/about/page.tsx still serves /about but inherits only (marketing)/layout.tsx — letting marketing pages use one shell while app/(shop)/products uses another, even coexisting at the same URL path level (only one may claim a given final path though). Groups solve real problems: separate root layouts for auth flows, applying Suspense/loading per section, organizing without polluting URLs. Private folders (_name) opt files out of the filesystem router entirely — components, utilities, fixtures sit next to the routes using them without creating accidental endpoints; the alternative $ prefix opts back INTO routing for unusual needs. Conflicts to watch: groups sharing a path must not define competing pages at identical URLs, and multiple root layouts require groups with each holding its own html/body. These features reward deliberate information architecture.
Example
app/
├─ (marketing)/
│ ├─ layout.tsx # marketing shell
│ └─ about/page.tsx # /about
├─ (shop)/
│ ├─ layout.tsx # shop shell w/ cart
│ └─ products/page.tsx # /products
└─ dashboard/
├─ _components/Chart.tsx # NOT a route
└─ page.tsx # /dashboardInterview tip
Draw the tree with both groups showing same-level URLs mapping to different layouts. The 'private folders prevent accidental routes' point shows attention to safety.
Common mistakes
- Creating duplicate paths across groups causing build conflicts.
- Not knowing _folders stay out of the router.