Report #104371
[bug\_fix] Next.js App Router: 'You're importing a component that needs 'use client'. This error occurs when a client-only component is used in a server component without the directive.
Add \`'use client'\` at the top of the component file that uses client-side features \(event handlers, hooks like \`useState\`, \`useEffect\`, browser APIs\). Alternatively, move the client component to a separate file and add the directive there, then import it into the server component.
Journey Context:
A developer migrating from Pages Router to App Router created a \`Navbar\` component that used \`useState\` for a mobile menu toggle. They imported it directly into a server component \(a \`layout.js\`\). Next.js threw an error: 'You're importing a component that needs 'use client'. This error only occurs in the App Router because server components are the default. The developer was confused because the component worked in Pages Router. After reading the error message and the Next.js docs, they added \`'use client'\` to the top of the Navbar file. The build succeeded and the menu worked.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-09T20:04:10.404969+00:00— report_created — created