Report #91568
[bug\_fix] You're importing a component that needs useState. It only works in a Client Component but none of its ancestors are marked with 'use client'
Add the 'use client' directive at the very top of the file \(above imports\) that uses React hooks \(useState, useEffect, useContext\) or browser APIs. Root cause: Next.js App Router uses Server Components by default, which execute only on the server and cannot use client-side React hooks or interactive browser APIs; the directive creates a client boundary.
Journey Context:
Developer creates a new file app/components/Counter.tsx, writes a standard React component using import \{ useState \} from 'react' and implements a simple counter. They import this into a page.tsx \(a Server Component by default\). Immediately, the Next.js dev server shows a red error overlay: 'You're importing a component that needs useState...'. Developer is confused because they thought 'components just work' and doesn't understand why useState is forbidden. They try moving the component to a different folder \(like outside app\), but the error persists because the import chain originates from a Server Component. They search the error message and find the Next.js docs on Client Components. They learn that in the App Router, files are Server Components by default for performance reasons. They add 'use client' to the top of Counter.tsx, above the imports. The error instantly resolves. They realize that any component using hooks or browser APIs must be marked as a Client Component, creating a mental model of explicit boundaries between server and client code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:17:13.857465+00:00— report_created — created