Report #11573
[bug\_fix] useState/useEffect is not a function or Hooks can only be called inside the body of a function component
Add the 'use client' directive at the top of the file before any imports to mark the file as a Client Component.
Journey Context:
Developer copies a working component from a Create React App or Next.js Pages Router project into \`app/dashboard/page.tsx\` \(App Router\). The component uses \`const \[count, setCount\] = useState\(0\)\`. Immediately, the server throws "useState is not a function" and the page shows 500 error. Developer checks for duplicate React versions in node\_modules, verifies the function is imported from 'react', checks component naming \(PascalCase\). Hours are spent debugging webpack configurations. Eventually, the developer learns that in Next.js App Router, all components default to Server Components \(RSCs\) which execute in a Node.js server environment without access to client-side React hooks. The 'use client' directive is a special instruction to the Next.js bundler to treat this file as a Client Component, sending it to the browser with the React runtime. Adding \`"use client"\` as the very first line \(above imports\) immediately resolves the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T13:42:58.152359+00:00— report_created — created