Route groups and multiple layouts
What you need to know
A route group organizes related pages without adding a word to their public URLs. Wrap a folder name in parentheses to give a section its own layout or keep its files together. River Books can separate shopping and support without making customers visit /shop/catalog or /support/help.
By the end, you can: organize routes without URL changes; detect conflicting paths.
Single-root route tree
app/ layout.tsx (shop)/ layout.tsx catalog/page.tsx (support)/ help/page.tsxExpected behavior (not framework-tested): The public paths are /catalog and /help. Both share the document layout; only /catalog receives the shop layout.
How it works
Parentheses affect routing, not component imports. Put a common document shell above the groups when navigation should preserve that shell. A group can also own a root layout when no ancestor layout exists; each root must provide html and body. A transition between distinct roots loads a new document, so state in the previous root does not persist. Keep the homepage in one group if there is no top-level root layout.
Two-root alternative (separate project tree)
app/ (shop)/ layout.tsx page.tsx catalog/page.tsx (staff)/ layout.tsx reports/page.tsxExpected behavior (not framework-tested): / belongs to the shop root; /reports belongs to the staff root. Moving between the roots performs a full page load.
Common mistake
Do not define app/(shop)/catalog/page.tsx and app/(staff)/catalog/page.tsx together: both claim /catalog. Rename a public segment or choose one owner. A group called (staff) does not authenticate anyone.
Practice and verification
Draw a route tree for /, /catalog and /help with one common navigation. Then propose two roots for a public website and staff portal, and explain which navigation loses shared state.
Scope: App Router, proposed Next.js 16.x, Cache Components disabled for these labs. Snippets assume a reviewed TypeScript app and are static examples; framework behavior has not been executed. Exact supported patch and dependency set must be verified before running.