Catalog project route map
Scope: Next.js 16.x candidate, App Router, Cache Components disabled, TypeScript. Source walkthroughs and expected outcomes; no framework build or browser execution has been verified.
What you will learn
- Design a small route tree
- Define expected page text
Project file tree — relevant route files
app/ layout.tsx page.tsx help/page.tsx catalog/page.tsx catalog/[slug]/page.tsx catalog/[slug]/not-found.tsxpublic/covers/moss.pnglib/books.tsRoutes: /, /help, /catalog and /catalog/moss (among valid slug values). /covers/moss.png is a public asset, not a page component.
How it works
The reference solution uses a single root layout; the catalog list owns filtering and pagination, the detail route owns lookup and missing-record handling, and help explains the demo. A dynamic segment is not a license to interpret arbitrary filesystem paths. Use a known slug to look up synthetic data. Keep assets outside route folders in public and use not-found.tsx for missing books. A project route table is an expectation document, not proof of a server response.
app/catalog/[slug]/page.tsx — reference solution
import Image from 'next/image';import { notFound } from 'next/navigation';import { getBook } from '../../../lib/books';import Quantity from '../Quantity';export default async function Detail({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const book = getBook(slug); if (!book) notFound(); return <><h1>{book.title}</h1><Image src={book.cover} alt="" width={240} height={360} style={{ maxWidth: '100%', height: 'auto' }} /> <p>{book.description}</p><p>${book.price}</p><Quantity key={book.slug} title={book.title} /></>;}A known slug displays its book. An unknown slug invokes notFound and renders the missing-book UI; HTTP status depends on response/streaming behavior and must be measured.
Common mistake
Do not create a separate hard-coded route for every book when one dynamic segment can map known identifiers. Conversely, do not allow arbitrary path strings to access files. Keep the data lookup bounded.
Try it yourself
Add a route contract for /catalog/fern and /catalog/unknown. Specify expected headings, whether the picker exists, and a return path to the catalog.
Further reading
Next lesson: Catalog UI integration.