Report #92376
[bug\_fix] Server Component cannot use Hooks \(useState/useEffect\) without 'use client'
Add the 'use client' directive at the very top of the file \(before any imports\) to indicate this is a Client Component where hooks are allowed. Alternatively, refactor to remove state \(e.g., use URL search params for state via server rendering\). Root cause: Server Components execute during the server render phase where React hooks don't exist; they are not part of the client React runtime.
Journey Context:
Developer new to the App Router creates a component and tries to use useState to manage a form input or toggle. Immediately gets an error 'You're importing a component that needs useState but it's a Server Component'. Developer is confused because it looks like a regular React function component. They try moving the hook inside a nested function, or adding 'use client' inside the component \(which fails\), or adding it after imports \(which fails\). After reading the error message carefully, they place 'use client' at the absolute top of the file and it works, or they realize they can lift the state up to a parent Client Component and pass it down as props to keep this one a Server Component.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:38:45.119848+00:00— report_created — created