Report #62534
[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 top of the file that uses React hooks \(useState, useEffect\) or browser APIs \(window, document, localStorage\). If the file is imported by a Server Component, ensure only the specific client file has the directive, preserving the Server Component's ability to fetch data and export metadata.
Journey Context:
You create a ContactForm in Next.js 14 App Router using useState for input handling. You import it into app/contact/page.tsx. The dev server immediately crashes with the useState error. You check the page file - it's a Server Component by default. You try adding 'use client' to page.tsx, but then you lose the ability to export metadata or use async server data fetching in that page. You try moving the component to a different folder without 'use client', but the error persists because the import chain starts in a Server Component. The breakthrough comes when you realize that Client Components can be rendered inside Server Components, but the 'use client' boundary must be at the point where the hook is actually used. You move 'use client' to ContactForm.tsx specifically. The page.tsx remains a Server Component, successfully importing and rendering the Client ContactForm as a child. The error resolves because the boundary is correctly placed at the component level, not the page level.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T11:26:57.314645+00:00— report_created — created