Dev Helpers
← Back

Issue number resolver

Place this file at app/issues/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/issues/page.tsx

export default async function IssueNumberResolver({
  searchParams,
}: {
  searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
  const issues = [
    { id: 12, title: "Header spacing", owner: "Kim", severity: 1, open: true },
    { id: 14, title: "Invoice rounding", owner: "Sam", severity: 3, open: true },
    { id: 21, title: "Alt text", owner: "Kim", severity: 2, open: false },
  ];
  const { id } = await searchParams;
  const issue = issues.find((i) => i.id === Number(id));
  return (
    <section>
      <h1>{issue?.title ?? "Issue lookup"}</h1>
      <p>{issue ? "Assigned to " + issue.owner : "Enter an issue number."}</p>
    </section>
  );
}