Report #39782
[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'
Add the directive 'use client' at the very top of the file \(above imports\) that uses the React hook or browser API.
Journey Context:
A developer migrates a project from Next.js Pages Router to App Router. They copy a working Counter component using useState into app/page.tsx. The dev server immediately throws an error: 'useState only works in Client Components'. Confused, they check imports and see React is imported. They search the error and land on the Next.js docs explaining the Server Component default in App Router. They realize hooks require the client boundary. They add 'use client' to the top of the file, save, and the error clears. They later realize they should have kept page.tsx as a Server Component and moved the interactive bit to a nested Client Component to preserve SSR benefits, but the immediate fix was the directive.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:14:50.092323+00:00— report_created — created