Report #74577
[bug\_fix] You're importing a component that needs useState. 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\) for any component using React hooks \(useState, useEffect\), browser APIs \(window, document\), or event handlers \(onClick\). Do not add it to the parent Server Component.
Journey Context:
Developer creates a Modal component with useState for open/close logic. They import it into a Server Component page in the App Router. The build fails immediately with an error about hooks not working in Server Components. Developer initially adds 'use client' to the page.tsx file, which fixes the error but causes the entire page to be client-side rendered, losing SEO benefits. After checking the Next.js architecture docs, they understand that the boundary should be at the component level. Moving 'use client' to the Modal.tsx file allows the page to remain a Server Component while the modal chunk is loaded separately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:46:41.461168+00:00— report_created — created