Dev Helpers
← Back

Known guide or not found

Place this file at app/guide/[slug]/page.tsx in an App Router project.

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>
  );
}