Report #102924
[bug\_fix] You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with 'use client', so they're Server Components or Server Components by default
Add the 'use client' directive at the top of the file that imports or defines client-only logic \(useState, useEffect, event handlers, browser APIs\). Keep the boundary as deep as possible; do not mark entire layouts as client components when only a small leaf needs interactivity.
Journey Context:
You scaffold a new Next.js App Router project and create app/page.tsx that imports a Counter from app/ui/counter.tsx. Counter uses useState and onClick. On the dev server you get a red error saying the component needs useState but is being treated as a Server Component. You first try adding 'use client' to page.tsx, which works but bloats the client bundle because now the whole page, including data-fetching code, is shipped to the browser. You then read the error message more carefully: the directive marks a module boundary, and everything imported into that module becomes part of the client graph. The right fix is to place 'use client' only in the smallest component that actually needs client features \(counter.tsx\). The Server Component page can still import and render the Client Component; Next.js will leave a placeholder in the RSC payload and hydrate it on the client. This keeps the server-rendered shell server-only and the interactive leaf interactive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-10T04:42:45.314331+00:00— report_created — created