Performance: Nested routes with folders
This affects the page load speed and initial rendering by organizing routes into folders, which impacts how Next.js bundles and serves pages.
app/
about/
page.js
team/page.js
careers/page.jspages/ about.js about-team.js about-careers.js
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Flat routes in single folder | Low (few nodes) | Low (few reflows) | High (larger bundles delay paint) | [X] Bad |
| Nested routes with folders | Low (few nodes) | Low (few reflows) | Low (smaller bundles speed paint) | [OK] Good |
page.tsx file inside a nested folder under app/ do?app/ represents a route segment in the URL.page.tsx in nested folderspage.tsx inside a nested folder creates a page for that nested route path./dashboard/settings in Next.js App Router?page.tsx file must be inside the deepest folder representing the route.app/:
app/
blog/
[slug]/
page.tsx
page.tsx
What URL will render the page inside app/blog/[slug]/page.tsx?[slug] represent dynamic route segments.:slug in URL patterns, meaning any value matches.app/
products/
page.tsx
details/
page.tsx
But navigating to /products/details shows a 404 error. What is the likely cause?details/page.tsx must be inside products/details/ folder to match the route /products/details.details/page.tsx inside app/ root, not nested under products/.details/page.tsx file is misplaced; it should be inside products/details/page.tsx. -> Option A/profile/settings/privacy in Next.js App Router. You also want to share a layout between /profile/settings and /profile/settings/privacy. How should you organize your folders and files inside app/?/profile/settings and /profile/settings/privacy, place layout.tsx inside settings/ folder.page.tsx inside settings/ and inside settings/privacy/ for those pages.Pass the test and this pattern moves unknown