Report #29037
[bug\_fix] You're importing a component that needs 'use client', but the module graph doesn't include it, or 'use client' directive is missing
Add the 'use client' directive at the very top of the file \(before imports\) that uses browser APIs, React hooks \(useState, useEffect\), or interactive event handlers \(onClick\), marking it as a Client Component boundary.
Journey Context:
You scaffold a new Next.js 14 project with the App Router. You create a simple Counter component using useState and an onClick handler, placing it in app/components/Counter.tsx. You import it into app/page.tsx \(which is a Server Component by default\). Upon saving, the dev server throws an error: 'useState is not defined' or 'Event handlers can only be used in Client Components'. You initially think it's a missing import, but realize React is imported. You check the file and notice there's no 'use client' directive. You recall that in the App Router, all components are Server Components by default, which cannot use hooks or event handlers. After adding 'use client' to the top of Counter.tsx, the error resolves and the interactive component hydrates correctly on the client.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:07:52.369151+00:00— report_created — created