0
0
NextJSframework~10 mins

Route groups with (groupName) in NextJS - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Route groups with (groupName)
Start: Define route group folder
Add (groupName) folder
Place pages/components inside group
Next.js reads routes
Group folder ignored in URL
Render pages as normal
End
Next.js reads route groups as folders with (groupName) and ignores them in the URL, organizing routes without changing paths.
Execution Sample
NextJS
app/(admin)/dashboard/page.tsx
export default function Dashboard() {
  return <h1>Admin Dashboard</h1>
}
Defines a page inside a route group folder (admin) that does not appear in the URL but organizes routes.
Execution Table
StepActionFolder/RouteURL PathResult
1Create folder with (admin)app/(admin)/Folder created but ignored in URL
2Add page.tsx inside (admin)app/(admin)/dashboard/page.tsx/dashboardPage route is /dashboard
3Next.js reads routesapp/(admin)/dashboard/page.tsx/dashboardRoute registered as /dashboard
4User visits /dashboardN/A/dashboardRenders Admin Dashboard page
5User visits /admin/dashboardN/A/admin/dashboard404 Not Found (no such route)
💡 Route group folder (admin) is ignored in URL, so /dashboard works but /admin/dashboard does not.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
Route PathN/AN/A/dashboard/dashboard/dashboard
Folder NameN/A(admin)(admin)/dashboard(admin)/dashboard(admin)/dashboard
Key Moments - 2 Insights
Why doesn't the folder name (admin) appear in the URL path?
Because Next.js ignores folders with parentheses in the URL, as shown in execution_table step 1 and 3.
What happens if I try to visit /admin/dashboard in the browser?
You get a 404 error because the route group folder is not part of the URL, as shown in execution_table step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the URL path for the page inside (admin)/dashboard at step 3?
A/(admin)/dashboard
B/admin/dashboard
C/dashboard
D/admin
💡 Hint
Check the 'URL Path' column at step 3 in the execution_table.
At which step does Next.js register the route ignoring the group folder?
AStep 3
BStep 2
CStep 1
DStep 5
💡 Hint
Look for when the route path is set in the execution_table.
If you rename (admin) to admin (without parentheses), what happens to the URL path?
AURL path remains /dashboard
BURL path includes /admin/dashboard
CRoute breaks and 404 always shows
DURL path becomes /(admin)/dashboard
💡 Hint
Route groups with parentheses are ignored in URL; removing them includes folder name in URL.
Concept Snapshot
Route groups in Next.js use folders named with parentheses, like (groupName).
These folders organize routes but do NOT appear in the URL path.
Pages inside route groups render normally at paths ignoring the group folder.
Use route groups to keep URLs clean while structuring code.
Example: app/(admin)/dashboard/page.tsx maps to /dashboard URL.
Full Transcript
In Next.js, route groups are folders named with parentheses, such as (admin). These folders help organize your app's routes without adding extra parts to the URL. When Next.js reads the routes, it ignores the group folder name in the URL path. For example, a page inside app/(admin)/dashboard/page.tsx will be accessible at /dashboard, not /admin/dashboard. This lets you keep your code organized without changing the URLs users see. If you try to visit /admin/dashboard, it will not work because the group folder is not part of the URL. This feature helps keep URLs clean and simple while allowing flexible folder structures.