Report #67686
[bug\_fix] Error: useState is not a function or Invalid hook call when using React hooks in Next.js App Router
Add the 'use client' directive at the very top of the file \(above imports\) to mark the file as a Client Component, allowing React hooks to execute in the browser.
Journey Context:
Developer creates a new Button component in app/components/Button.tsx, imports useState from 'react', and calls it to manage a hover state. Immediately on importing the component into a page, the dev server crashes with "Error: useState is not a function". Developer checks package.json for duplicate React versions, runs npm ls react, and verifies only one version exists. They check the React DevTools which shows the component tree but indicates hooks are failing. After reading the error stack pointing to the Server Component boundary, the developer realizes that in the App Router, all components are Server Components by default, and hooks only work in Client Components. They add 'use client' to the top of Button.tsx and the error resolves.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:05:23.372715+00:00— report_created — created