Report #11248
[bug\_fix] Error: useState is not a function or Hooks can only be called inside the body of a function component when using React hooks in a Server Component.
Add the \`'use client'\` directive at the very top of the file \(before any imports\) to mark the module as a Client Component, allowing React hooks to execute in the browser.
Journey Context:
Developer creates a new file \`app/components/Counter.tsx\` and writes a standard React component using \`useState\` to manage a count. They import this into \`app/page.tsx\` \(which is a Server Component by default in the App Router\). Upon loading the page, the app crashes immediately with "useState is not a function". The developer checks their React version \(18\+\), checks for duplicate React copies in node\_modules, and verifies the syntax is correct. After searching the error, they realize that in the Next.js App Router, all components are Server Components by default, which execute in a Node.js environment where hooks do not exist. They find the solution in the Next.js docs: adding \`'use client'\` to the top of \`Counter.tsx\`. After adding the directive and restarting the dev server, the component works. The developer then learns to keep components as Server Components whenever possible for performance, only using \`'use client'\` when interactivity is required.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T12:51:16.665864+00:00— report_created — created