Report #102878
[bug\_fix] You're importing a component that needs to use hooks but it's not a client component.
Add the \`'use client'\` directive at the top of the file that contains the component using hooks, or ensure the component is only used within client components.
Journey Context:
I was refactoring a legacy Next.js project to use the App Router. I had a shared \`Button\` component that used \`useState\` for a loading state. I imported it into a new server component layout. The build failed with an error saying the component needs to be marked as a client component. I initially tried to move the hook usage to a parent client component and pass props down, but the Button was deeply nested. I then realized the simplest fix: add \`'use client'\` at the top of the Button file. That tells Next.js to treat it as a client component, bundling it separately. The root cause is that server components cannot have state or effects; any file that uses React hooks must be a client component. The fix works because the directive forces the component to be rendered on the client, preserving interactivity while still allowing server components to import it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T15:49:17.095940+00:00— report_created — created