completefrontend

Predict the outputEasy

One page is a Server Component and the other starts with "use client". What does next build print for each?

The tea shop has two pages. The home page lists the teas. The cart page starts with "use client" and keeps a cup count in useState. The app is new, so Cache Components is on, as create-next-app sets it up. What does the route table say about each page, and what does the HTML the server sends for /cart show?

app/layout.tsx
import Link from "next/link";
 
export const metadata = { title: "Leaf and Kettle" };
 
export default function RootLayout({ children }: LayoutProps<"/">) {
  return (
    <html lang="en">
      <body>
        <nav>
          <Link href="/">Teas</Link> <Link href="/cart">Cart</Link>
        </nav>
        {children}
      </body>
    </html>
  );
}
app/page.tsx
const teas = ["Green tea", "Mint tea", "Oolong tea"];
 
export default function Home() {
  return (
    <main>
      <h1>Our teas</h1>
      <ul>
        {teas.map((tea) => (
          <li key={tea}>{tea}</li>
        ))}
      </ul>
    </main>
  );
}
app/cart/page.tsx
"use client";
 
import { useState } from "react";
 
export default function CartPage() {
  const [cups, setCups] = useState(0);
  return (
    <main>
      <h1>Your cart</h1>
      <p>
        Cups: {cups} <button onClick={() => setCups(cups + 1)}>Add a cup</button>
      </p>
    </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.
  2. You run next start and ask the server for /cart.

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…