Next.js: React client hook in a Server Component
In the App Router, components are Server Components by default and can't use client hooks like useState or useEffect. Add 'use client' at the top of the file that uses the hook, or move the interactive part into a small client component.
Cause: A hook that needs the browser runs in a component without the 'use client' directive.
How to fix it
- Find the component using the hook (the error points to it).
- Add
'use client'as the first line of that file. - Keep data fetching in Server Components; pass data to the client component as props.
- Don't mark whole layouts as client unless needed.
Example
Illustrative example, not from a customer project.
+ 'use client'
import { useEffect } from 'react'
FAQ
Does 'use client' hurt SEO?
Client Components are still prerendered to HTML; they just also hydrate in the browser.
Why did this appear after migrating to the App Router?
The Pages Router had no Server Components; the App Router defaults to them.
QUICK FIX · $49 · THIS ERROR ONLY
Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- Read-only access; fixes arrive as pull requests you merge.
- Your $149 diagnosis is credited in full toward any paid job.
One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.
Bigger job: Getting the whole app live? Launch Path, $1,195 flat.
Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.