Report #60617
[bug\_fix] You're importing a component that needs useState. It only works in a Client Component but none of your ancestors is a client entry...
Add \`'use client'\` directive at the absolute top of the file \(before imports\) where the hook is used. Root cause: Next.js App Router defaults to Server Components which run only on the server; React hooks require client-side execution context.
Journey Context:
Developer creates \`app/components/Counter.tsx\` with \`const \[count, setCount\] = useState\(0\)\`. They import it into \`app/page.tsx\`. Immediate error: 'useState' is not allowed in Server Components. They check the file - it's a .tsx file in a components folder, not a special server file. They learn that in Next.js App Router, every component is a Server Component by default unless opted out. They try moving the file to \`app/counter/page.tsx\` but same error. They search the error and find the 'use client' directive. They add it above the imports: \`'use client'\`. The error disappears and the counter works. They realize this directive tells the bundler to create a client bundle for this file and its imports, sending it to the browser to execute. They also learn to minimize 'use client' usage by composing components - keeping the parent as a Server Component and passing children slots to Client Components.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:13:52.596489+00:00— report_created — created