Report #64362
[bug\_fix] Missing 'use client' directive when using hooks in App Router
Add the string \`"use client"\` \(including the quotes\) as the very first line in the file, before any imports or code.
Journey Context:
Developer creates a new file \`app/components/Counter.tsx\` and writes \`const \[count, setCount\] = useState\(0\)\`. Immediately, the dev server shows an error: "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'..." The developer is confused because they are used to Pages Router where all components are client-side by default. They try adding \`"use client"\` below the imports, which fails because directives must be at the very top of the file. They try adding it to the parent layout.tsx, but then realize that marks the entire subtree as client-side, losing the benefits of Server Components. Eventually, they understand that any file using hooks, browser APIs, or event handlers must have \`"use client"\` as its first line, and that providers should be isolated in wrapper components to minimize client boundaries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:31:01.347530+00:00— report_created — created