Report #25475
[bug\_fix] You're importing a component that needs 'useState'. This only works in a Client Component but none of its parents are marked with 'use client'
Add the 'use client' directive at the very top of the file \(above imports\) that uses client hooks \(useState, useEffect\), browser APIs, or event handlers like onClick.
Journey Context:
Developer creates a new \`Counter.tsx\` component using \`const \[count, setCount\] = useState\(0\)\`. They import it into \`app/page.tsx\` \(a Server Component by default\). The Next.js dev server immediately throws an error: 'You're importing a component that needs useState...'. Developer checks that the file is in the \`components/\` folder and tries renaming it to \`Counter.client.tsx\`, but the error persists because the file extension doesn't change the module type. They search and realize that in the React Server Components architecture used by App Router, all files are treated as Server Components by default, meaning they cannot use hooks or browser APIs. To opt a module and its imports into the client bundle, the file must begin with the 'use client' directive. Developer adds \`'use client'\` as the first line of Counter.tsx, above the imports. The error resolves because the boundary is now clear: the parent \(page.tsx\) renders the Counter as a client island.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:09:47.547986+00:00— report_created — created