Common Next.js errorsuseState only works in a Client Component
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. The same message appears for useEffect, useContext and event handlers like onClick.
Why it happens
In the App Router every component is a Server Component unless its file says otherwise. Server Components render once on the server and never re-render, so state, effects and browser events don't exist there.
How to fix it
Add 'use client' as the very first line of the file that uses the hook, above the imports:
'use client'
import { useState } from 'react'
export function Counter() {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(count + 1)}>{count}</button>
}
Keep the boundary as low as you can: mark the small interactive piece, not the whole page, so the rest still renders on the server and ships less JavaScript. If a third-party component uses hooks but has no 'use client' of its own, re-export it from a file of yours that does.