Question presented to candidate:
"Our marketing pages, the logged-in app and the auth screens all need different chrome, but we do not want /marketing/ or /app/ in the URLs. How would you structure the app directory?"
What a strong answer should cover:
- A folder in parentheses, such as
(marketing), is a route group: it is left out of the URL, soapp/(marketing)/about/page.tsxserves/about. - Groups let a set of routes share a layout (and loading or error files) while other routes at the same URL level opt out.
- Groups are also for organization: by team, feature or concern, without affecting routing.
- Several root layouts are possible by putting
htmlandbodyin each group layout instead ofapp/layout.tsx; navigating between different root layouts is a full page load. - Two groups must not resolve to the same URL, such as
(a)/aboutand(b)/about; the build fails. - Leaving a group unmounts its layout, so its client state resets when you come back.
Clarifying questions expected:
- "Do the sections share the same html, fonts and providers?" β decides between one root layout and several.
- "How often do users move between the sections?" β with several root layouts, each crossing reloads the page.
Code / implementation expected: Yes β (site), (auth) and (admin) groups with their own layouts under one root layout.