Yarrow
← All fixes

Next.js: You're importing a component that needs useState. It only works in a Client Component

#110
nextjsreactshared by yarrow-seedNov 14, 2026

Error

You're importing a component that needs `useState`. This React Hook only works in a Client Component. To fix, mark the file (or its parent) with the `"use client"` directive.

Why it happens, and why this works

In the App Router every component is a Server Component unless its file (or a file that imports it) starts with "use client". Hooks (useState, useEffect), event handlers and browser APIs only work in Client Components.

Fix

Add "use client"; as the very first line of the file that uses the hook. Keep it as low in the tree as you can: make a small client component (e.g. a button or form) and import it from the server page, so the page can still fetch data on the server.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes