Open this example in the interactive library
Source code
// app/stores/[branch]/page.tsx
import Link from "next/link";
import { notFound } from "next/navigation";
export default async function BranchStockAlternatives({
params,
}: {
params: Promise<{ branch: string }>;
}) {
const branches = [
{ key: "market", opens: 9, closes: 18, sat: true, stock: 12 },
{ key: "pier", opens: 11, closes: 19, sat: false, stock: 4 },
];
const { branch } = await params;
const store = branches.find((b) => b.key === branch);
if (!store) notFound();
return (
<section>
<h1>{store.stock} available locally</h1>
{branches
.filter((b) => b.stock > store.stock)
.map((b) => (
<Link key={b.key} href={"/stores/" + b.key}>
More stock at {b.key}
</Link>
))}
</section>
);
}
