Report #84390
[bug\_fix] Missing 'use client' directive when using browser-only hooks or APIs
Add the 'use client' directive at the very top of the file \(before imports\) that uses useState, useEffect, document, window, or other client-side-only code.
Journey Context:
Developer creates a Counter component using useState and useEffect in a new file, then imports it into a page.tsx in the App Router. Immediately, the dev server throws: 'Error: You're importing a component that needs useState. This only works in a Client Component but none of its parents are marked with 'use client''. Developer checks the file - no directive. They try adding 'use client' to the parent page, but that forces the entire page to be client-side rendered, breaking other Server Component imports. They eventually realize that only the leaf component that actually needs interactivity needs the directive, and that Server Components can import Client Components, but not vice versa without passing them as children props.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:14:38.430890+00:00— report_created — created