Report #6489
[bug\_fix] You're importing a component that needs useState/useEffect/Window. It only works in a Client Component but none of its parents are marked with "use client"
Add the 'use client' directive at the very top of the file \(above imports\) where the browser API or React hook is used. If the component needs to be a Server Component for data fetching but has interactive children, extract the client-only UI into a separate file with 'use client' and import it into the Server Component.
Journey Context:
Developer migrates a working Pages Router component to the App Router. The component uses useState or accesses window.localStorage. Upon running the dev server, they get a hard error stating the component must be a Client Component. They try adding 'use client' but accidentally place it below the imports or inside a function, causing a syntax error. After fixing placement, they realize their data fetching logic \(which worked in getServerSideProps\) now needs to be restructured because Client Components can't be async in the same way. They refactor to either keep the parent as a Server Component \(removing 'use client'\) and pass data down to a client child, or move the fetch into useEffect within the 'use client' component.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:14:20.448700+00:00— report_created — created