Part 06 / Topic 4 of 6
Common mistake, reproduced for real: marking the whole page "use client"
The instinctive fix for "I need some interactivity on this page" is often to put "use client" at the very top of the page file itself, rather than on the one small piece that actually needs it. Tried directly against QuickAddPage — adding nothing but the directive at the top of the exact same file from section 1 — the build doesn't just get slower or bigger, it fails outright, for a very specific and very real reason:
$ npm run build
...
Error: Turbopack build failed with 1 error:
./app/store/(shop)/quick-add/[id]/page.tsx:16:8
Error: Next.js can't recognize the exported `generateStaticParams` field in route. App pages cannot use both "use client" and export function "generateStaticParams()".
...
The exported configuration object in a source file needs to have a very specific format from which some properties can be statically parsed at compiled-time.
generateStaticParams is the function Part 2 section 4 already established as mandatory for any dynamic route under this harness's cacheComponents: true default — and a page simply isn't allowed to both export it and be a Client Component at the same time. The two features are mutually exclusive at the page level, not just awkward to combine. This isn't the only cost of drawing the boundary too high (a Client Component page would also lose the direct findProduct()/notFound() access Part 5 relied on, and would need to receive the product as a prop from somewhere else instead), but it's the one that stops the build in its tracks rather than quietly shipping more JavaScript than necessary. The real fix is section 1's layout: keep the page a Server Component, push "use client" down to AddToCartCounter and ExpandablePanel only. The broken version was reverted immediately after capturing this error.
Done here? The practice set for Part 6 — including the solutions — is on the part page.