Next.js: a client hook was used in a Server Component
The build says a component needs useState or useEffect and only works in a Client Component? Next.js wants 'use client' at the top of that file.
Reviewed October 15, 2026
What it means in plain English
The page is a Server Component, and the file calls a React hook that only runs in the browser, such as useState or useEffect. Next.js stops the build and says you are using a React client hook in a Server Component.
Likely causes
- The AI added a click handler or a piece of state to a file that had no
'use client'line. - A shared component used a hook, and a server page imported it.
- The directive was added under the imports, so Next.js did not treat the file as a client file.
How to fix it, step by step
- Open the file named in the error. Next.js says to mark the component that uses the hook as a Client Component.
- Put
'use client'on the first line, above the imports. Next.js's before-and-after example is anuseEffectcomponent that starts working after that line is added. - Leave data loading in a Server Component when you can. Pass the loaded values into the client file as props. Do not mark the whole app as a client just to silence one hook.
- Redeploy.
How to check it worked
next buildfinishes without the client-hook message.- The button or effect still runs in the browser.
Sources
Related fixes
More Next.js errors fixes
Keep going on your own.
The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.