Report #104575
[bug\_fix] 'use client' boundary error when using hooks or client components in a Server Component
Add the directive 'use client' at the top of the file that uses client-side features \(e.g., useState, useEffect, onClick, browser APIs\). Alternatively, move the client logic into a separate file with 'use client' and import it into the Server Component.
Journey Context:
Developer was migrating a Next.js 13 app to App Router. They created a new page component and tried to use \`useState\` to manage a toggle. Next.js threw 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'.' They thought all components in the \`app\` directory were client components by default. After reading the Next.js docs on Server vs Client Components, they realized that all components in App Router are Server Components by default unless explicitly marked. Adding 'use client' at the top of the file resolved the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:07:20.231140+00:00— report_created — created