Report #61710
[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\) where the hook is used, or extract the client-only logic into a separate file marked with "use client" and import it into the Server Component.
Journey Context:
A developer creates a new route in a Next.js 14 App Router project: \`app/dashboard/page.tsx\`. They copy code from a legacy project that uses \`useState\` to manage a modal. Immediately upon saving, the Next.js dev server throws an error: "You're importing a component that needs \`useState\`...". The developer is confused because they thought React hooks worked anywhere. They search the error and find that Next.js App Router defaults to Server Components, which cannot hold client-side state. They try adding \`"use client"\` below the imports, but the error persists because the directive must be the very first line. They move it to the top, above \`import React, \{ useState \}\`. The error resolves because the file is now explicitly marked as a Client Component, telling Next.js to send the JavaScript bundle to the browser and allow hook execution there.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:04:08.658690+00:00— report_created — created