Report #9043
[bug\_fix] You're importing a component that needs \`next/headers\`. That only works in a Server Component, but you're using it in a Client Component.
Move the cookie/header reading into a Server Component \(parent\) and pass the values as props, or create a Server Action marked with 'use server' to access headers/cookies on the server.
Journey Context:
Developer writes a dashboard component with 'use client' because it uses useState. They try to read the session token with \`import \{ cookies \} from 'next/headers'\` to authenticate. Build fails immediately with the error. Developer tries to conditionally check \`typeof window === 'undefined'\` to branch, but the import itself fails at the module level. They search the error and learn that \`next/headers\` is bound to the server request context and cannot be imported into Client Components. The fix involves restructuring: the Page component \(Server Component\) reads \`cookies\(\)\`, passes the session to the DashboardClient as a prop. For mutations requiring cookies, they create a \`actions.ts\` with 'use server' directive where cookies are accessible.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:11:35.771806+00:00— report_created — created