Coding task · Next.js course · Module 2: Routing and Layouts
Comprehensive App Router - Step by Step
One dynamic page combines the [id] segment, metadata from generateMetadata, notFound() for a wrong address and navigation with Link. You will build the whole shop with nested layouts, slots and modals in the project of the next task.
Task
Combine several App Router features in one file, app/products/[id]/page.tsx, step by step: 1) export async function generateMetadata({ params }) returns { title: 'Product ' + id }; 2) export default async function ProductPage({ params }) reads id with await params; 3) if id is not made of digits only, call notFound() from next/navigation; 4) otherwise return a main element with an h1 heading “Product {id}” and a Link component (next/link) that leads to /products.