completefrontend

Predict the outputHard

generateStaticParams lists only Green tea. What do the first and second visits to /teas/oolong get, and what does the terminal print?

The tea page builds only the best seller ahead of time: its generateStaticParams returns green alone. The part that needs the slug awaits params inside <Suspense>, and logs the slug it renders. Cache Components is on, as create-next-app sets it up. What does each request get, what does its HTML hold before the streamed part arrives, and what does the terminal print during the build and the three requests?

app/layout.tsx
export const metadata = { title: "Leaf and Kettle" };
 
export default function RootLayout({ children }: LayoutProps<"/">) {
  return (
    <html lang="en">
      <body>
        <header>Leaf and Kettle</header>
        {children}
      </body>
    </html>
  );
}
lib/teas.ts
export type Tea = { slug: string; name: string; about: string };
 
export const teas: Tea[] = [
  { slug: "green", name: "Green tea", about: "Light and fresh." },
  { slug: "mint", name: "Mint tea", about: "Cool and sweet." },
  { slug: "oolong", name: "Oolong tea", about: "Rich and smooth." },
];
 
export function getTea(slug: string) {
  return teas.find((tea) => tea.slug === slug);
}
app/teas/[slug]/page.tsx
import { Suspense } from "react";
import { notFound } from "next/navigation";
import { getTea } from "@/lib/teas";
 
export function generateStaticParams() {
  return [{ slug: "green" }];
}
 
async function TeaDetails({ params }: { params: PageProps<"/teas/[slug]">["params"] }) {
  const { slug } = await params;
  console.log(`Rendering ${slug}`);
  const tea = getTea(slug);
  if (!tea) notFound();
 
  return (
    <>
      <h1>{tea.name}</h1>
      <p>{tea.about}</p>
    </>
  );
}
 
export default function TeaPage({ params }: PageProps<"/teas/[slug]">) {
  return (
    <main>
      <Suspense fallback={<p>Loading the tea…</p>}>
        <TeaDetails params={params} />
      </Suspense>
    </main>
  );
}

It's a project create-next-app made (Next.js 16.4.3, TypeScript, the App Router, and Cache Components on) with these files, built with next build and run with next start. What happens:

  1. You run next build, then next start.
  2. You ask the server for /teas/green.
  3. You ask it for /teas/oolong, the first visit to that tea since the build.
  4. You ask for /teas/oolong again.

The answer

Work out what Next.js does at each step: what the build prints, what each request answers, and what the page shows. Then check.

Checking your sign-in…