I’ve been developing with Next.js for a while now, and with every major release, we get introduced to new features that make our workflow even better.
However, there’s one feature I believe many developers overlook. I rarely see it used in codebases I work on, and I honestly wonder why. Is it because they don’t know it exists? Or they’re not sure how it actually works?
So in today’s article, I’m going to introduce you to a Next.js feature called Route Groups. Once you understand this, you’ll be ahead of many Next.js developers.
What Exactly Are Route Groups?
I’m not going to give you a textbook definition. Instead, I'll show you how they work and why they matter.
Let’s say your design team delivers 4 sets of designs for your company's MVP:
- Website – marketing and legal pages
- Authentication – sign in, sign up, forgot password
- Dashboard – protected pages for signed-in users
- Public Profile – profile pages accessible publicly
Each of these sections has its own unique layout:
Website → Header + Footer
Dashboard → Header + Sidebar + Footer
Auth → Minimal layout
Profile → Custom layout
Now you’re thinking:
“What’s the best way to give each section its own layout without messing up the folder structure?”
This is where Next.js Route Groups come in.
How Route Groups Work
You create a route group by wrapping a folder name in parentheses:
(website)
(auth)
(dashboard)
(profile)
By doing this, you're telling Next.js:
“Don’t include this folder in the final URL. It’s only for organization.”
Once you do that, some powerful features become available.
1. Root Layouts per Route Group
Each route group can have its own layout.js or layout.tsx.
Example folder structure:
app/
(website)/
layout.js
(auth)/
layout.js
(dashboard)/
layout.js
(profile)/
layout.js
This means you can:
Give website pages a shared header and footer
Give dashboard pages a shared sidebar and protected layout
Give auth pages a minimal layout
Give profile pages their own custom structure
All without messing up your URLs.
2. Layout Logic
Every layout can contain unique logic.
Example:
This makes it easy to protect routes without middleware.
3. Shared SEO Metadata
If SEO matters for your project, you can define shared metadata in each root layout.
Example:
Page-level metadata will override layout metadata when needed.
But There Are Caveats
To avoid getting confused, here are a few things you must keep in mind.
1. Full Page Reload Between Layouts
When navigating between pages that use different root layouts, Next.js triggers a full page reload.
Example:
/about → uses (website) layout
/login → uses (auth) layout
Navigating between them will reload the page.
This only happens when switching between multiple root layouts.
2. Conflicting Paths
Avoid creating routes in different groups that resolve to the same URL.
Example:
app/(website)/about/page.js // → /about
app/(profile)/about/page.js // → /about ❌ conflict
This will throw route resolution errors.
3. No Top-Level Layout? Then One Group Must Define /
If you don't have a global app/layout.js and you're using multiple root layouts, one of them must contain your homepage:
app/(website)/page.js // becomes "/"
Final Thoughts
Once you understand these caveats, you’ll be able to use the power of Next.js Route Groups seamlessly.
Let me know what you think about Route Groups in the comments.
Have you used this before, or are you trying it for the first time after reading this?


Top comments (0)