Report #96216
[bug\_fix] useState is not a function or Hooks can only be called inside the body of a function component \(in Server Component\)
Add the 'use client' directive as the very first line of the file \(before imports\) to mark the file as a Client Component, enabling React hooks. Alternatively, refactor to remove hooks if the component can be a Server Component.
Journey Context:
Developer creates a new file app/components/Counter.tsx and uses useState to manage a click count. They import it into a page.tsx. Immediately the app crashes with an error saying useState is not a function or that hooks are invalid. They check React imports and versions, then realize that in the App Router, all components are Server Components by default. Server Components cannot use hooks or browser APIs. They find the solution in the Next.js docs: adding 'use client' at the top of the file. They add it, save, and the component works because Next.js now treats it as a Client Component, shipping the JS to the browser to run hooks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:04:52.801205+00:00— report_created — created