Report #101439
[bug\_fix] You're importing a component that needs useState. It only works in a Client Component but none of your parents are marked with 'use client'
Add the \`'use client'\` directive at the very top of the file that uses browser-only APIs \(useState, useEffect, window, document, localStorage, etc.\) or any component that imports such code. Keep the boundary as deep as possible; do not mark entire pages as client components unless necessary, so the rest of the tree stays server-rendered.
Journey Context:
A developer extracts a reusable \`\` component into its own file and uses \`useState\`. The Next.js dev server immediately throws "You're importing a component that needs useState. It only works in a Client Component..." because Next.js App Router defaults to Server Components. The dev first adds \`'use client'\` to the page file, which fixes the error but makes the entire page client-rendered and removes SEO benefits. They move the directive to the top of \`Counter.tsx\` only. The error goes away and the page remains a Server Component. They document that any utility that touches \`window\` or \`document\` must also live behind a client boundary, because Server Components cannot access browser globals.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:51:28.284050+00:00— report_created — created