Report #40412
[bug\_fix] You're importing a component that needs useState, but it's a Server Component
React Server Components cannot use hooks or browser APIs. The error occurs when a file containing useState, useEffect, or DOM refs is imported into a Server Component without the 'use client' directive. The fix is to add the string literal 'use client' at the absolute top of the file \(before imports\) that contains the hook usage. This creates a client boundary, telling Next.js to bundle that file for browser execution.
Journey Context:
You migrate a page from Pages Router to App Router. You move a form into app/dashboard/page.tsx and get a red error saying hooks can't be used. App Router defaults to Server Components. You add 'use client' to page.tsx, which works but makes the entire page client-side rendered, defeating App Router's benefits. You refactor: create Form.tsx with 'use client' at the top, keeping page.tsx as a Server Component that imports Form. The page renders the static shell on the server, then hydrates the interactive form. The error disappears and you get partial hydration benefits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:18:07.365726+00:00— report_created — created