Report #26263
[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 directive \`'use client'\` at the very top of the file \(before imports\) that uses client-side hooks \(useState, useEffect\) or browser APIs. This opts the component into client-side rendering in the Next.js App Router.
Journey Context:
Developer creates a new component \`Counter.tsx\` using \`useState\` to manage a click count. They import this into a \`page.tsx\` in the App Router. Immediately, the dev server throws an error saying hooks can't be used in Server Components. Developer tries moving the component to a \`components\` folder, tries renaming to \`.client.tsx\`, but the error persists. They check imports and realize App Router defaults all components to Server Components. After reading the error message carefully, they add \`'use client'\` as the first line of \`Counter.tsx\`, above the imports. The error disappears immediately because this tells Next.js to send this component's code to the browser and execute it there, rather than rendering it on the server during the initial HTML generation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:29:04.135871+00:00— report_created — created