Report #15161
[bug\_fix] You're importing a component that needs \`useState\`. This React hook only works in a client component. To fix, mark the file with a 'use client' directive.
Add the string literal 'use client' at the top of the file \(before imports\), or refactor to move the interactive logic into a child Client Component while keeping the parent as a Server Component.
Journey Context:
Developer creates a new component in the App Router, imports \`useState\` or \`useEffect\`, and uses it. They import this component into a \`page.tsx\` or \`layout.tsx\` \(Server Components\). Immediately, the Next.js dev server shows an error overlay explaining that hooks only work in client components. The developer initially thinks they need to install React or that there's a version mismatch. After reading the error, they add 'use client' to the top of their component file. The error disappears. Later, they learn that this opts the entire subtree into client-side rendering, so they refactor to keep data fetching in the Server Component and pass results as props to a smaller 'use client' component that handles the interactivity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:19:35.835458+00:00— report_created — created