What are route groups?
Route Groups in Next.js are a way to logically group routes without affecting the URL.
They let you bring order to the app/ structure without changing page addresses.
In other words:
a route group is a folder in parentheses that exists only for the developer, not for the user.
What route groups look like
A route group is a folder whose name is in parentheses:
app/
├─ (auth)/
│ ├─ login/
│ │ └─ page.tsx → /login
│ └─ register/
│ └─ page.tsx → /register
└─ (marketing)/
└─ page.tsx → /The (auth) folder never appears in the URL.
Why route groups are needed
1. Logical organization of the project
You can group routes by meaning:
- authentication
- marketing
- admin panel
- the public part
At the same time, URLs stay clean and understandable.
2. Different layouts for the same URL levels
Route groups are often used to:
- have different layouts
- for pages at the same URL level
- but with a different UI structure
Example:
app/
├─ (public)/layout.tsx
├─ (admin)/layout.tsxBoth groups can contain a / page, but with a different layout (via nested segments).
3. Isolating layouts and logic
Each route group can have its own:
- layout
- loading
- error
- middleware logic
- providers
This is convenient when:
- different parts of the site "live their own life"
- you don't want to mix code
4. Clean and predictable URLs
Route groups let you:
- avoid adding technical segments to the address
- avoid creating
/auth/loginwhen you want/login - keep a nice link structure
The URL is designed for the user, the folders are for the developer.
Important features
(group)never appears in the URLlayout.tsxcan be used inside a group- groups do not affect URL nesting
- can be combined with nested layouts
An example with layout
app/
├─ (auth)/
│ ├─ layout.tsx
│ └─ login/
│ └─ page.tsx → /login
├─ (main)/
│ ├─ layout.tsx
│ └─ page.tsx → /Here:
/loginuses theauthlayout/uses themainlayout- URLs stay clean
Summary
Route groups are needed to:
- logically organize routes
- apply different layouts
- keep the URL uncluttered
- isolate logic and providers
In short: route groups are an architectural tool for order in the project, not for user navigation.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.