Report #64150
[bug\_fix] You're importing a component that needs "use client". It only works in a Client Component but none of its parents are marked with "use client"
Add the 'use client' directive at the very top of the file \(before any imports\) that contains the hook usage or browser API access. This marks the module and its imports as Client Components, allowing React hooks to work. Alternatively, refactor to keep data fetching in a Server Component and pass results as props to a Client Component wrapper.
Journey Context:
Developer creates a new component in the Next.js App Router \(app directory\) and tries to use \`useState\`, \`useEffect\`, or imports a component from a library like \`react-select\` that uses hooks. Immediately gets an error stating that hooks can only be used in Client Components and that none of the parents are marked with 'use client'. Developer is confused because they thought all React components could use hooks by default. They learn that in the App Router, components are Server Components by default \(running only on the server\), which cannot use browser-only APIs or hooks. Developer tries to add 'use client' but places it after the import statements, which causes a syntax error. Eventually, they learn that 'use client' must be the very first line in the file, before any imports. This directive tells Next.js to treat that file and its dependencies as a Client Component boundary, allowing hooks to function normally. They also learn the architectural pattern: keep data fetching in Server Components, pass data down to Client Components for interactivity, rather than making everything a Client Component.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:09:54.720869+00:00— report_created — created