Introduction
Route groups help organize routes in Next.js without changing the URL. They keep your files tidy and your URLs clean.
Route groups help organize routes in Next.js without changing the URL. They keep your files tidy and your URLs clean.
app/(groupName)/page.tsx // Example folder structure: // app/(admin)/dashboard/page.tsx // app/(admin)/settings/page.tsx // The URL will be /dashboard and /settings, not /admin/dashboard or /admin/settings
Route groups are folders wrapped in parentheses like (groupName).
They do not add to the URL path but help organize files.
(marketing) folder show as /home and /about URLs.app/(marketing)/home/page.tsx app/(marketing)/about/page.tsx
(dashboard) folder appear as /profile and /settings URLs.app/(dashboard)/profile/page.tsx app/(dashboard)/settings/page.tsx
Both pages are inside the (admin) group folder. The URLs will be /dashboard and /settings without /admin in the URL.
// Folder structure: // app/(admin)/dashboard/page.tsx // app/(admin)/settings/page.tsx // app/(admin)/dashboard/page.tsx export default function Dashboard() { return <h1>Admin Dashboard</h1>; } // app/(admin)/settings/page.tsx export default function Settings() { return <h1>Admin Settings</h1>; }
Route groups help keep URLs clean while organizing code.
They are useful for sharing layouts or components among grouped pages.
Route groups use parentheses in folder names to group routes without changing URLs.
They keep your project organized and URLs simple.
(groupName) in Next.js?admin in Next.js?(groupName).(admin) correctly creates a route group called admin.app/(dashboard)/page.tsx
app/(dashboard)/settings/page.tsx
app/profile/page.tsx
(dashboard) group is invisible in URL, so app/(dashboard)/page.tsx maps to / because the page.tsx inside is the root of that group. Similarly, app/(dashboard)/settings/page.tsx maps to /settings. The app/profile/page.tsx maps to /profile.(admin) inside app but your routes under it are not working. What is the most likely mistake?page.tsx or similar file inside to define the route component.(admin) don't work, missing page.tsx is the most common cause.page.tsx file inside the (admin) folder -> Option A(marketing) and (sales) inside app with pages home.tsx and contact.tsx each. How should you organize folders so URLs are /home and /contact without group names in URL?home.tsx inside (marketing) and contact.tsx inside (sales) keeps URLs as /home and /contact.app/(marketing)/home.tsx and app/(sales)/contact.tsx -> Option CPass the test and this pattern moves unknown