A folder named in parentheses, app/(shop)/cart/page.js, is a route group: it serves /cart, not /shop/cart. Groups exist to attach layouts to a subset of routes without changing URLs. Two groups must not resolve to the same path; (marketing)/about and (shop)/about fail the build.
What a group changes is the layout tree, and navigation follows that tree:
- A layout inside a group (under a shared root layout) wraps only the group's routes. Moving between two routes in the group keeps it mounted with its state; moving out of the group unmounts it. The navigation is still client-side.
- Multiple root layouts. Delete
app/layout.jsand give each group its own layout with<html>and<body>; each is then a root layout. A root layout owns the document, so the router can't swap one for another inside the same React tree. A<Link>from/cart((shop)) to/blog((marketing)) does a full page load: a new document request, the JavaScript state and any client caches gone. Within one root layout, navigation stays soft.
Use multiple root layouts when sections really differ at the document level: separate fonts, global CSS, <html lang>, or an admin app that shares nothing with the marketing site. The cost is a full reload whenever users cross between them, so keep sections people move between often under one root.
Without app/layout.js, the home page must live in a group (app/(shop)/page.js), and there's no single layout for a global 404. The experimental global-not-found.js covers that case.
A root layout under a dynamic segment (app/[lang]/layout.js) is still one root layout: switching /en to /fr stayed client-side in testing.