Open this example in the interactive library
Source code
// app/kitchen/[dish]/page.tsx
import { notFound } from "next/navigation";
export default async function RecipeBatchCount({
params,
}: {
params: Promise<{ dish: string }>;
}) {
const menu = [
{ slug: "soup", mins: [10, 25], ingredients: ["lentils", "stock"], serves: 4 },
{ slug: "toast", mins: [3, 4], ingredients: ["bread", "oil"], serves: 2 },
];
const { dish } = await params;
const recipe = menu.find((r) => r.slug === dish);
if (!recipe) notFound();
return (
<table>
<caption>Batches for a group</caption>
<tbody>
{[4, 8, 12].map((n) => (
<tr key={n}>
<th>{n} guests</th>
<td>{Math.ceil(n / recipe.serves)} batches</td>
</tr>
))}
</tbody>
</table>
);
}
