Next.js: Event handlers cannot be passed to Client Component props
Event handlers cannot be passed to Client Component props.Short answer
In the App Router, pages and layouts are Server Components, and a function cannot be sent from the server to the browser as a prop. onClick on a plain element in a Server Component, or a callback prop passed to a Client Component, causes this error. Put the handler inside a file marked use client, or pass a Server Function marked use server.
Fix it fast
1Find out which cause you have
The error names the element and the prop, for example onClick. Find that JSX and check the first line of the file it lives in. No 'use client' directive means it is a Server Component, and the handler must move.
head -3 app/page.tsx grep -rnE "on[A-Z][a-zA-Z]+=\{" app | head -302Match what you see, then jump to its fix
- 1
The file has no 'use client' line and renders a button, input or form with onClick, onChange or onSubmit.A handler is written in a Server ComponentFix - 2
The component receiving the prop already has 'use client', but the page that renders it passes onSave, onSelect or a similar callback.A function is passed as a prop from server to clientFix - 3
The handler is inside a library component and your own file has no onClick of its own.A third-party component that needs the browser is used in a Server ComponentFix
- 1
What does the error look like?
Event handlers cannot be passed to Client Component props.onClick in a Server Component, or a callback prop sent to a Client Component
Cause 1 of 3
A handler is written in a Server Component
1Check
State and event handlers need a Client Component. Next.js treats layouts and pages as Server Components by default.
head -5 app/page.tsx2Fix
Move only the interactive part into its own file that starts with 'use client', and import it into the page. Keep the page on the server, so data fetching stays there.
// app/ui/like-button.tsx
'use client'
import { useState } from 'react'
export default function LikeButton({ likes }: { likes: number }) {
const [count, setCount] = useState(likes)
return <button onClick={() => setCount(count + 1)}>{count} likes</button>
}
// app/page.tsx (still a Server Component)
import LikeButton from '@/app/ui/like-button'
export default function Page() {
return <LikeButton likes={12} />
}3Verify
Reload the page and click the button. The count changes and the error is gone.
npm run devConfirmed by nextjs.org
Cause 2 of 3
A function is passed as a prop from server to client
1Check
Props that cross from a Server Component to a Client Component must be serializable. A plain function, a class instance or an unregistered symbol is not.
grep -rnE "<[A-Z][A-Za-z]+[^>]* on[A-Z][A-Za-z]*=\{" app | head -302Fix
Either define the function inside the Client Component, or write it as a Server Function with 'use server' and pass that. Functions exported from a module that has use client are fine inside that module's tree.
// app/actions.ts
'use server'
export async function saveNote(formData: FormData) {
// write to the database here
}
// app/page.tsx (Server Component)
import { saveNote } from './actions'
import NoteForm from './ui/note-form'
export default function Page() {
return <NoteForm action={saveNote} />
}3Verify
Submit the form. The request reaches the Server Function and no prop error is shown.
npm run devConfirmed by react.dev
Cause 3 of 3
A third-party component that needs the browser is used in a Server Component
1Check
A library that uses state or handlers but does not mark its entry with use client cannot run in a Server Component.
grep -rn "use client" node_modules/PACKAGE/dist 2>/dev/null | head -32Fix
Wrap the library component in your own Client Component file and import that wrapper instead.
// app/carousel.tsx
'use client'
import { Carousel } from 'acme-carousel'
export default Carousel3Verify
Import the wrapper in the page and reload.
npm run devConfirmed by nextjs.org
How do I stop it coming back?
- Add 'use client' to small leaf components that need state or events, not to whole pages.
- Pass data as props from the server, and keep callbacks inside the Client Component or as Server Functions.
- Keep forms on Server Functions with the form action prop where you can.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Next.js shows Application error: a client-side exception has occurred
An error in production with a digest and no readable message
This white page is Next.js's fallback when an uncaught error unmounts the React tree, and it hides the real message.
4 causes, each with a fixWeb apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fixWeb apps
There is no tailwind.config.js after installing Tailwind 4 and HeroUI in Next.js
HeroUI components render unstyled
Nothing is broken: Tailwind CSS 4 is configured in CSS and no longer creates tailwind.config.js.
3 causes, each with a fixWeb apps
react-i18next shows the wrong plural form for a count, or prints the key instead of the text
t('item') prints the key item instead of a translated sentence
i18next picks a plural from the count option and looks for keys ending in _one, _other and so on.
4 causes, each with a fixWeb apps
useSession throws because there is no SessionProvider above it
[next-auth]: `useSession` must be wrapped in a <SessionProvider />
useSession reads the session from React Context, and SessionProvider is what creates that context.
3 causes, each with a fixWeb apps
next/link throws React.Children.only on its children
Error: React.Children.only expected to receive a single React element child.
React.Children.only accepts exactly one React element and throws for anything else, including an array with one item.
3 causes, each with a fix