Report #8504
[bug\_fix] You're importing a component that needs \`useState\` but none of its ancestors are marked with "use client"
Add the directive \`"use client"\` at the very top of the file \(before imports\) that contains the hook usage, or move the hook logic to a dedicated Client Component wrapper. Root cause: Next.js App Router defaults to React Server Components \(RSC\) which execute once on the server and cannot hold client-side state or effects; the explicit directive opts that file and its children into the client bundle.
Journey Context:
Developer creates a \`Counter.tsx\` component with \`const \[count, setCount\] = useState\(0\)\` and a button to increment. They import this into \`app/page.tsx\` \(which defaults to a Server Component\). Immediately, the dev server crashes with the exact error: "You're importing a component that needs \`useState\`...". The developer is confused because they have used useState many times in Create React App. They search the error and find Next.js docs explaining the App Router architecture. They try adding \`"use client"\` to \`page.tsx\`, which fixes the error but converts the entire page to client-side rendering, losing the benefits of SSR. They realize they should add the directive only to \`Counter.tsx\`, keeping the page as a Server Component that imports a Client Component. The error resolves and they understand the client-server boundary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:41:52.276955+00:00— report_created — created