Open this example in the interactive library
Source code
// app/guide/[slug]/page.tsx
import Link from "next/link";
import { notFound } from "next/navigation";
export default async function KnownGuideOrNotFound({
params,
}: {
params: Promise<{ slug: string }>;
}) {
const { slug } = await params;
const guides: Record<string, string> = {
start: "Getting started",
deploy: "Deployment",
};
if (!Object.hasOwn(guides, slug)) notFound();
return (
<main>
<h1>{guides[slug]}</h1>
<Link href="/guide">All guides</Link>
</main>
);
}
