Report #4156
[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 \`"use client"\` directive at the very top of the file \(above imports\) that uses client-side hooks or browser APIs, or create a wrapper Client Component that imports the UI library and is then imported by the Server Component.
Journey Context:
Developer creates a new route in the App Router \(e.g., \`app/dashboard/page.tsx\`\) and imports a third-party UI component \(e.g., from \`@headlessui/react\`\) that internally uses \`useState\`. Upon saving, the dev server throws the error immediately. Developer checks the import path and node\_modules. They realize the component uses React hooks. They learn that in the App Router, all components are Server Components by default and cannot use hooks. They try adding \`"use client"\` to the page.tsx, which fixes it but makes the entire page client-side rendered. The optimized fix is to keep the page as a Server Component and move the interactive UI into a separate file \(e.g., \`DashboardClient.tsx\`\) with \`"use client"\`, then import that wrapper into the page. This preserves the Server Component architecture while isolating client interactivity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:54:27.871756+00:00— report_created — created