Next.js App Router: Patterns That Actually Work
Real-world patterns for the Next.js App Router — parallel routes, intercepting routes, loading UI, error boundaries, and streaming with Suspense.
The App Router Mental Model
The App Router isn't just a new file structure — it's a fundamentally different way of thinking about rendering. Every folder is a route segment. Every page.tsx is a UI. Every layout.tsx wraps its children persistently.
Loading UI with Suspense
// app/[locale]/blog/loading.tsx
export default function Loading() {
return (
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
{Array.from({ length: 6 }).map((_, i) => (
<div key={i} className="rounded-2xl bg-gray-100 animate-pulse h-64" />
))}
</div>
);
}
Error Boundaries
// app/[locale]/blog/error.tsx
"use client";
export default function Error({
error,
reset,
}: {
error: Error;
reset: () => void;
}) {
return (
<div className="text-center py-20">
<h2>Something went wrong</h2>
<button onClick={reset}>Try again</button>
</div>
);
}
Parallel Routes
Show multiple pages simultaneously in the same layout:
app/
@modal/
(.)blog/[slug]/
page.tsx ← intercepted route (modal)
blog/
[slug]/
page.tsx ← full page
layout.tsx ← renders both @modal and children
Streaming with Suspense
import { Suspense } from "react";
export default function Page() {
return (
<div>
<h1>Blog</h1>
{/* This streams in as soon as it's ready */}
<Suspense fallback={<PostsSkeleton />}>
<Posts />
</Suspense>
</div>
);
}
async function Posts() {
const posts = await fetchPosts(); // Can be slow
return <PostList posts={posts} />;
}
Route Groups
Organize routes without affecting URLs:
app/
(marketing)/
page.tsx → /
about/page.tsx → /about
(app)/
dashboard/ → /dashboard
settings/ → /settings
The App Router rewards understanding its mental model. Once it clicks, building complex applications becomes surprisingly straightforward.
Written by
Soren Lindqvist
Engineer. Ships the TypeScript, Docker, and database pieces, usually after breaking them in production first.
Related Articles
React Server Components Explained
Everything you need to know about React Server Components — what they are, how they differ from client components, and when to use each.
State Management in 2024: What Actually Works
Redux is no longer the default answer. Compare Zustand, Jotai, TanStack Query, and React's built-in tools to find the right solution for your app.
Web Performance: Beyond Core Web Vitals
Core Web Vitals are just the start. Learn advanced performance techniques including resource hints, code splitting, and the new INP metric.