Dev Helpers
← Back

Build stage duration table

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

Open this example in the interactive library

Source code

// app/builds/[number]/page.tsx

import { notFound } from "next/navigation";

export default async function BuildStageDurationTable({
  params,
}: {
  params: Promise<{ number: string }>;
}) {
  const builds = [
    { n: 101, sha: "4d8af31", steps: [12, 18, 9], ok: true },
    { n: 102, sha: "28bc70a", steps: [10, 24, 6], ok: false },
  ];
  const { number } = await params;
  const run = builds.find((b) => String(b.n) === number);
  if (!run) notFound();
  return (
    <table>
      <caption>Build {number}</caption>
      <tbody>
        {run.steps.map((s, i) => (
          <tr key={i}>
            <th>{["Install", "Test", "Bundle"][i]}</th>
            <td>{s}s</td>
          </tr>
        ))}
      </tbody>
    </table>
  );
}