Route Groups
Master route groups in Next.js — the parentheses folder pattern that organises your app without affecting URLs, enabling multiple layouts and clean code organisation.
Last reviewed: January 2025
🔍 What Is It?
Route groups are folders named with parentheses in the app/ directory. They:
- →Do not appear in the URL —
(marketing)/about/page.tsxmaps to/about - →Apply layouts to sections — each group can have its own
layout.tsx - →Organise code — group related routes without URL pollution
- →Enable multiple root layouts — different top-level layouts for different app sections
Naming convention: Use descriptive names that reflect the section's purpose: (marketing), (dashboard), (auth), (admin).
🎯 Why Do We Need It?
Without route groups, you face a choice:
- →One layout for everything — marketing pages get the dashboard sidebar (wrong)
- →URL-based sections —
/app/dashboardand/app/settings(ugly URLs) - →Manual layout switching — every page manually includes the right layout (error-prone)
Route groups let you have /dashboard and /pricing with completely different layouts, clean URLs, and zero manual wiring.
🏗️ What Happens in Real Projects?
Route group architecture for a SaaS product:
app/
├── layout.tsx # Root layout (html, body)
├── (marketing)/ # No URL segment
│ ├── layout.tsx # Marketing layout: public header + footer
│ ├── page.tsx # / (homepage)
│ ├── pricing/page.tsx # /pricing
│ └── blog/
│ └── [slug]/page.tsx # /blog/my-post
├── (auth)/ # No URL segment
│ ├── layout.tsx # Auth layout: centered card
│ ├── login/page.tsx # /login
│ └── register/page.tsx # /register
└── (dashboard)/ # No URL segment
├── layout.tsx # Dashboard layout: sidebar + auth guard
├── dashboard/page.tsx # /dashboard
└── settings/page.tsx # /settings⚙️ How It Works
Route group resolution:
- Next.js sees
(marketing)/pricing/page.tsx - Strips the
(marketing)segment from the URL - The route resolves to
/pricing - The layout chain is:
RootLayout > MarketingLayout > PricingPage - No
/marketingappears in the URL
Multiple root layouts: You can have multiple layout.tsx files at the route group level that each include their own <html> and <body> tags. This is useful for completely different apps (e.g., a public site and an admin panel) that share the same Next.js project.
💻 Example
Route Groups in Practice — Three route groups with different layouts — marketing, auth, and dashboard.
🤔 Common Confusions
❓ Do route groups affect URL structure?
No — that is the entire point. (marketing)/pricing/page.tsx maps to /pricing, not /marketing/pricing. The parentheses tell Next.js to exclude this folder from the URL. Use regular folders (without parentheses) when you want the folder name to appear in the URL.
❓ Can I have the same URL in two different route groups?
No — that would create a conflict. Since route groups are URL-transparent, (marketing)/about/page.tsx and (other)/about/page.tsx would both map to /about, causing a build error. Each URL must map to exactly one page.
❓ Do I need route groups for every project?
No — small apps with one layout do not need route groups. Use them when you have genuinely different sections of your app that need different layouts (public vs authenticated, marketing vs product). Do not over-engineer a simple app.
🚨 Common Production Issues
Accidentally creating duplicate routes — moving a page into a route group without checking if the URL already exists in another group. Always verify the URL mapping after restructuring.
Auth guard in wrong group — adding a page to the (dashboard) group but forgetting that the group's layout has an auth guard. The page is now protected. Intentional, but easy to overlook.
Route group naming confusion in teams — without a documented convention, teams create inconsistent group names. Establish a convention: (public), (protected), (admin) or (marketing), (app), (auth).
✅ Best Practices
Use route groups for every distinct app section with a different layout
Name groups after their purpose: (marketing), (dashboard), (auth), (admin)
Document your route group structure in the project README for new team members
Put auth guards in the group layout, not individual pages
Use (private) or _ prefix for internal folders that should not be routes
🏛️ Architect's Note
Route groups are the primary tool for layout architecture in Next.js. Before writing a single page, design your route group structure. Ask: how many distinct UI shells does this app have? Each answer is a route group. This upfront architecture decision prevents painful refactoring later when you realise the marketing pages need a completely different header than the dashboard.
💬 Frequently Asked Questions
🎯 Key Takeaways
🔗 Related Topics
🎯 Practice this topic in interviews
↗ Where this topic fits
Next.js Technology Guide
Return to the Next.js learning hub.
Frontend Engineer Career Path
A beginner-friendly journey through web foundations, React, production frontend engineering, and interview preparation.
Full Stack Java Developer Career Path
A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.
Sources
Sources / References
Use these Next.js references to verify the concept in official docs and continue into the most relevant SplashRide pages.
Official documentation
Related SplashRide pages
SplashRide Next.js learning path
Browse the full Next.js topic collection and learning order on SplashRide.
Next.js Interview Prep
Practice Next.js interview questions and scenario-based answers.
Frontend Engineer Career Path
A beginner-friendly journey through web foundations, React, production frontend engineering, and interview preparation.
Full Stack Java Developer Career Path
A guided route through frontend foundations, Java backend engineering, delivery workflows, and interview readiness.
Nested Routes & Layouts
Master nested routing and layouts in Next.js — how layouts compose, persist across navigation, and enable complex UI architectures without prop drilling.
Dynamic Routes
Master dynamic routes in Next.js — [slug], [...slug], [[...slug]] patterns, generateStaticParams, and how to handle every routing scenario in production.