Report #99596
[bug\_fix] Next.js App Router: You're importing a component that needs useState but the page is a Server Component
Add the \`"use client"\` directive at the top of the file that uses client-only React features \(useState, useEffect, event handlers, browser APIs\). Keep as much code as possible in Server Components; do not mark entire pages as client components just because one small leaf needs interactivity. Move the interactive leaf to its own file with \`"use client"\` and import it from the server component.
Journey Context:
You create \`app/dashboard/page.tsx\` and add a search input with \`const \[query, setQuery\] = useState\(''\)\`. On save you get a runtime error: \`You're importing a component that needs useState. This only works in a Client Component\`. You first try adding \`"use client"\` to \`page.tsx\`, which fixes the error but now the entire page is shipped to the browser and you lose the SEO and data-fetching benefits of Server Components. You then refactor: you create \`app/dashboard/SearchBox.tsx\` with \`"use client"\` at the top, move the input and state there, and import \`\` into the server \`page.tsx\`. The page remains a Server Component and only the search box bundle is sent to the client. The error is resolved because the boundary is now correctly placed at the component that actually needs client-side React.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:44:38.363314+00:00— report_created — created