Report #16336
[bug\_fix] You're importing a component that needs 'use client' but was imported without it
Add the \`"use client"\` directive as the very first line of the file that uses React Hooks \(useState, useEffect, useContext\) or browser APIs. If the component is imported by a Server Component, ensure the client boundary is at the point where the hook is used, not necessarily where it's imported. Root cause: Next.js App Router Server Components execute in a Node.js environment without a DOM or React client runtime; hooks require the client bundle to function.
Journey Context:
Developer creates a reusable \`Counter.tsx\` component with \`const \[count, setCount\] = useState\(0\)\` and saves it in \`app/components/Counter.tsx\`. They import it into \`app/page.tsx\` \(which defaults to a Server Component\). The Next.js dev server immediately throws the error: "You're importing a component that needs 'use client' but was imported without it... Counter.tsx". Developer initially tries moving the \`useState\` logic into the page file, but the error persists because the hook is still being invoked during server rendering. After consulting the Next.js documentation, developer understands that the boundary must be explicit. They add \`"use client"\` at the top of \`Counter.tsx\`, which tells Next.js to treat that module as a Client Component, ensuring it only renders in the browser where hooks are available.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:23:26.891425+00:00— report_created — created