What is the App Router introduced in Next.js 13?
The App Router is the app/ directory routing system built on React Server Components. It introduced nested layouts, server-first components, streaming and colocated special files, and it is the recommended router for all new Next.js apps.
Timeline
- Next.js 13 (2022): introduced in beta.
- 13.4: declared stable.
- 14: Server Actions became stable.
- 15: Request APIs (
params,cookies(),headers()) became async andfetchstopped caching by default. - 16: Turbopack by default, Cache Components (
"use cache"),proxy.ts, and synchronous request APIs fully removed. - 16.4: new apps enable Cache Components and Partial Prefetching by default.
Core ideas
- Server Components by default. Components run on the server and can be
async. Add"use client"only for interactivity. - Special files per segment.
layout,page,loading,error,not-found,template,defaultandroute. - Nested layouts that persist and keep state across navigations.
- Streaming.
loading.tsxand<Suspense>let parts of the page render while others wait for data. - Colocation. Components, tests and styles can sit next to routes; only
pageandroutefiles become public. - Advanced routing. Route groups
(name), parallel routes@slot, intercepting routes(.).
Compared to the Pages Router
Data is fetched inside components rather than in getServerSideProps. Mutations use Server Functions rather than API routes. Caching is explicit with "use cache" instead of page-level revalidate. Navigation uses next/navigation hooks (useRouter, usePathname, useSearchParams).
Pitfall
Putting "use client" at the top of a high-level layout turns the whole subtree into client code, losing most App Router benefits. Keep client boundaries at the leaves.
Code example
1// app/dashboard/layout.tsx - persists across /dashboard/* navigations2export default function DashboardLayout({ children }: LayoutProps<"/dashboard">) {3 return (4 <section className="grid grid-cols-[220px_1fr]">5 <aside>Sidebar (state survives navigation)</aside>6 <div>{children}</div>7 </section>8 );9}1011// app/dashboard/loading.tsx - shown instantly while page.tsx streams12export default function Loading() { // (app/dashboard/loading.tsx)13 return <p>Loading dashboard…</p>;14}1516// app/dashboard/page.tsx - async Server Component17import { db } from "@/lib/db";1819export default async function DashboardPage() {20 const stats = await db.stats.summary();21 return <h1>{stats.activeUsers} active users</h1>;22}
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.