Performance: Route groups with (groupName)
This affects the routing structure's impact on bundle size and initial page load speed by organizing routes without adding extra URL segments.
app/(admin)/dashboard/page.tsx
// Using (admin) as a route group keeps URL as /admin/dashboard without /admin prefixapp/admin/dashboard/page.tsx
// Using folders without parentheses adds extra URL segments like /admin/dashboard| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using folders without groupName (adds URL segments) | No extra DOM nodes | No reflows | Minimal paint cost | [X] Bad |
| Using route groups with (groupName) to hide folders | No extra DOM nodes | No reflows | Minimal paint cost | [OK] Good |
(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