Next.js App Router Architecture
How the App Router works: folder-based routing, nested route hierarchies, component tree evaluation, and streaming.
Next.js App Router Architecture
The App Router is built on React Server Components and nested routing to deliver optimal performance and clean separation of concerns.
1. Folder-Based Route Mapping
In the App Router, every folder represents a route segment that maps to a URL path segment. A route is only publicly accessible when a page.tsx file is added inside that folder:
app/
├── page.tsx ──► /
├── about/
│ └── page.tsx ──► /about
└── blog/
├── page.tsx ──► /blog
└── [slug]/
└── page.tsx ──► /blog/my-post2. Nested Hierarchy Evaluation
When a user visits /blog/my-post, Next.js renders the component tree hierarchically from the root down to the leaf page:
<RootLayout>
<BlogLayout>
<Suspense fallback={<Loading />}>
<ErrorBoundary fallback={<Error />}>
<PostPage params={{ slug: "my-post" }} />
</ErrorBoundary>
</Suspense>
</BlogLayout>
</RootLayout>Related Topics
Next.js App Router Project Structure
Understanding Next.js folder organization: special file conventions (page, layout, loading, error, not-found, route), public assets, and components.
Layouts and Root Layout in Next.js
Mastering Next.js layouts: RootLayout (<html>/<body>), nested layouts, state preservation across route changes, and Layout vs Template.