Report #13403
[bug\_fix] useState/useEffect is not allowed in Server Components \(missing 'use client'\)
Add the directive "use client" at the very top of the file \(before imports\) to mark the boundary as a Client Component.
Journey Context:
Developer creates a new component file with useState hook and imports it into a page.tsx in the App Router. Immediately gets a hard error: "You're importing a component that needs useState. It only works in a Client Component..." The developer tries renaming the file to .client.tsx or moving it to a components folder, but the error persists. They search the error message and discover that Next.js App Router defaults to Server Components. The fix isn't a file naming convention—it's a string literal directive "use client" that must be the first line of the file. This string tells Next.js to send that module to the client bundle and treat it as a client entry point.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:42:39.121679+00:00— report_created — created