Report #84856
[bug\_fix] Error: useState only works in Client Components. Add the 'use client' directive at the top of the file to use it.
Add the string \`'use client'\` as the very first line of the file, before any imports. Root cause: Next.js App Router defaults to Server Components; hooks like useState/useEffect require the client runtime and must be explicitly opted into the client bundle.
Journey Context:
Developer creates a new file \`Counter.tsx\` inside \`app/components/\` and writes a standard React component using \`useState\` to manage a count. As soon as they import it into a page, the dev server crashes with the error stating hooks only work in Client Components. The developer is confused because they didn't opt into Server Components intentionally. They search the error and realize that in the App Router, every component is a Server Component by default unless marked otherwise. They add \`'use client'\` at the top of the file, above the React import, and the error resolves immediately. They now understand this directive creates the client boundary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:01:08.446123+00:00— report_created — created