You add an onClick to a component in the App Router, save the file, and Next.js answers with a red screen:

Error: Event handlers cannot be passed to Client Component props.
  <... onClick={function onClick} children=...>
If you need interactivity, consider converting part of this to a Client Component.

Next prints carets under the function, and the page returns a 500. Nothing is wrong with your syntax. You ran into the rule that defines the App Router: code that runs on the server cannot hand a function to code that runs in the browser. This guide explains why, shows the code that triggers the error and walks through four fixes.

I reproduced every error and every fix below in a small App Router project on Next.js 16.4.3 with React 19.3.1. The message comes from React's server renderer, so the same text appears in Next.js 13.4, 14 and 15 as well, but I only ran version 16. Server Actions, used in the third fix, became stable in Next.js 14.

Server Components, Client Components and the boundary

In the App Router, every component is a Server Component unless its file starts with the 'use client' directive. The two kinds behave differently:

  • Server Components run only on the server. Their code is never sent to the browser, so they can read a database, use secrets and wait for data. They cannot use state, effects or event handlers.
  • Client Components are the files marked with 'use client', plus everything they import. Next.js renders them on the server too, to produce the first HTML, and then hydrates them in the browser so that clicks and state work.

The second point surprises many people. A Client Component is not client-only. In my test, a button inside a Client Component appeared as <button>Save <!-- -->42</button> in the HTML that the server sent.

The line between the two kinds is the boundary. When a Server Component renders a Client Component, React has to describe that Client Component and its props to the browser. It does this by serializing them into the React Server Components payload, a stream of JSON-like text with references to other parts of the tree.

Why functions cannot cross it

A function is not just text. It is code plus the variables it captured, such as a database connection or a request object. There is no meaningful way to write that into a payload, and the browser could not run a function that lives in a server process anyway. A click happens in the browser, so the handler has to exist in the browser.

That is the whole error: you wrote a handler in a place where it can only exist on the server, and then asked React to send it to the browser.

What can cross the boundary

  • Strings, numbers, booleans and null
  • Arrays and plain objects, including nested ones
  • Dates, Sets and Maps. A route that passed all three rendered without an error.
  • Server Actions, which travel as references and not as code (the third fix)
  • JSX, including Server Components passed as children (the fourth fix)

Class instances fail with a different message:

Error: Only plain objects, and a few built-ins, can be passed to Client Components
from Server Components. Classes or null prototypes are not supported.

Code that triggers the error

Scenario A: a handler passed from a page to a client button

// app/products/page.tsx  (a Server Component: no directive at the top)
import SaveButton from './SaveButton';

export default function ProductsPage() {
  function handleSave() {
    console.log('saved');
  }

  return <SaveButton onClick={handleSave}>Save product</SaveButton>;
}
// app/products/SaveButton.tsx
'use client';

import type { ReactNode } from 'react';

export default function SaveButton({ onClick, children }: { onClick: Function; children: ReactNode }) {
  return <button onClick={onClick}>{children}</button>;
}

The page is a Server Component, handleSave lives on the server, and SaveButton is a Client Component. Passing the handler over that line produces the event handler error from the start of this guide. An inline onClick={function () { ... }} or an arrow function fails in the same way.

Scenario B: a helper function with a different prop name

// app/counter/page.tsx
import Counter from './Counter';

function addOne(n: number) {
  return n + 1;
}

export default function CounterPage() {
  return <Counter increment={addOne} />;
}
// app/counter/Counter.tsx
'use client';

import { useState } from 'react';

export default function Counter({ increment }: { increment: Function }) {
  const [count, setCount] = useState(0);

  function handleClick() {
    setCount(increment(count));
  }

  return <button onClick={handleClick}>Count: {count}</button>;
}

Here the prop is called increment, not onClick, and the message changes:

Error: Functions cannot be passed directly to Client Components unless you explicitly
expose it by marking it with "use server". Or maybe you meant to call this function
rather than return it.
  <... increment={function increment}>

The cause is the same. If your error starts with Functions cannot be passed directly, read it as the event handler error for a prop with another name.

Scenario C: a handler on a plain element in a Server Component

// app/page.tsx
export default function Page() {
  function handleClick() {
    console.log('hi');
  }

  return <button onClick={handleClick}>Save</button>;
}

No Client Component is involved, and you still get Event handlers cannot be passed to Client Component props. A handler on an HTML element must run in the browser, so the element needs to live in a Client Component.

Two lookalike errors

  • Adding state to a page, for example useState, without the directive gives You're importing a module that depends on `useState` into a React Server Component module. This API is only available in Client Components. To fix, mark the file (or its parent) with the "use client" directive. The fix is the same idea as below.
  • Passing a class instance fails with the Only plain objects error shown earlier. Convert it to a plain object first.

Fix 1: put the interactive part in its own client file

Move whatever needs a handler or state into a small file that starts with 'use client', and render it from the server page:

// app/components/LikeButton.tsx
'use client';

import { useState } from 'react';

export default function LikeButton() {
  const [likes, setLikes] = useState(0);

  function handleClick() {
    setLikes(likes + 1);
  }

  return <button onClick={handleClick}>Likes: {likes}</button>;
}
// app/page.tsx  (still a Server Component)
import LikeButton from './components/LikeButton';

export default function Page() {
  return <LikeButton />;
}

There is also a shortcut: put 'use client' at the top of the page itself. In my test, the scenario A page then rendered with status 200. It works, but the whole page becomes a Client Component, and anything that must stay on the server, such as a direct database call, has to move out. Use it only when the entire page really is interactive.

Fix 2: let the client component own its handler and pass plain data

Often the page only needs to tell the client component what to work on. Pass an id or a value, and define the handler where the click happens:

// app/products/SaveButton.tsx
'use client';

import { useState } from 'react';

export default function SaveButton({ id }: { id: number }) {
  const [saved, setSaved] = useState(false);

  function handleClick() {
    setSaved(true);
  }

  return <button onClick={handleClick}>{saved ? 'Saved' : 'Save'} #{id}</button>;
}
// app/products/page.tsx
import SaveButton from './SaveButton';

export default async function ProductsPage() {
  const id = 42; // in a real page, this comes from your data
  return <SaveButton id={id} />;
}

The page fetches on the server, the button handles the click in the browser, and only a number crosses the boundary.

Fix 3: pass a Server Action instead of a function

When a click or a form submission must change something on the server, such as saving a record, do not send a handler across. Send a Server Action, a function marked with 'use server' that React exposes to the browser as a reference:

// app/actions.ts
'use server';

export async function saveProduct(formData: FormData) {
  const title = formData.get('title');
  // check the user's permissions, validate the input, then write to your database
}
// app/products/SaveForm.tsx
'use client';

import type { saveProduct } from '../actions';

export default function SaveForm({ action }: { action: typeof saveProduct }) {
  return (
    <form action={action}>
      <input name="title" defaultValue="New product" />
      <button type="submit">Save</button>
    </form>
  );
}
// app/products/page.tsx
import SaveForm from './SaveForm';
import { saveProduct } from '../actions';

export default function Page() {
  return <SaveForm action={saveProduct} />;
}

In my test, this route rendered with status 200, and the form markup contained a hidden field whose name starts with $ACTION_ID. That field is how the server action travels. Two more results from the same test:

  • An action defined inline inside the Server Component, with 'use server' as the first line of the function body, also worked.
  • The prop name did not matter at runtime. onSave={saveProduct} worked like action={saveProduct}. In an editor with Next.js's TypeScript plugin, a function prop whose name does not end in Action may still show a warning.

Treat every Server Action as a public endpoint. A browser calls it with a POST request, and so can anyone else who knows how. Check permissions and validate the input inside the action, exactly as you would in an API route.

Fix 4: compose with children and send only serializable props

If the problem is that your interactive wrapper needs server-rendered content inside it, you do not need to pass anything special. Pass that content as children:

// app/components/Modal.tsx
'use client';

import { useState, type ReactNode } from 'react';

export default function Modal({ children }: { children: ReactNode }) {
  const [open, setOpen] = useState(true);

  function toggle() {
    setOpen(!open);
  }

  return (
    <div>
      <button onClick={toggle}>Toggle details</button>
      {open && <section>{children}</section>}
    </div>
  );
}
// app/orders/page.tsx
import Modal from '../components/Modal';

async function OrderDetails({ id }: { id: number }) {
  const order = await getOrder(id); // your own server-side data function
  return <p>{order.title}</p>;
}

export default function OrdersPage() {
  return (
    <Modal>
      <OrderDetails id={7} />
    </Modal>
  );
}

The Modal owns the open and close state in the browser, while OrderDetails stays a Server Component that talks to your database. In my test, a Server Component passed as children rendered without any error, and its text was part of the HTML.

Check what actually crosses the boundary

When you are unsure what a Client Component receives, look at the page source and search for self.__next_f.push. Those script tags carry the payload. I passed an object with a test value to a Client Component, and the page source showed it in two places: once in the rendered markup, and once in the payload, in a line shaped like this (shortened):

["$","$L41",null,{"data":{"label":"hello"}},"$39","$3d",1]

Everything you pass to a Client Component is visible to the user. Do not pass tokens, API keys or internal ids that should stay private. Pass the minimum, and let Server Components and Server Actions keep the secrets.

A quick serializability test also helps. JSON.stringify drops function values silently, so if you print a props object with it and a field is missing, that field was a function.

Debugging companions for payload data

The payload is not plain JSON, because of references such as $L41, but the data you pass is. Paste the props object or the API response that feeds it into the JSON Validator to confirm that it is valid, and into the JSON Formatter to read long nested data. If you work with authentication, the JWT Decoder shows the claims inside a token that you found in a cookie or a header while debugging. The decoding runs in your browser, but avoid pasting production tokens into any online tool, and never solve a prop problem by passing a token to a Client Component.

Habits that avoid the error

  • Keep Server Components near the root. Fetch data, read the database and use secrets there.
  • Push 'use client' down to the leaves. A small button or form that needs interactivity should be the Client Component, not the page around it.
  • Do not put 'use client' on a page unless the whole page must be interactive.
  • Pass plain data across the boundary: ids, strings, numbers and simple objects.
  • Use Server Actions for mutations and validate and authorise inside them.
  • Read the prop name in the error. It points to the exact function that crossed the line.

FAQs

Does adding 'use client' make my whole Next.js app render on the client?

No. The directive marks a boundary. That file and the modules it imports become Client Components, and the rest of the tree stays on the server. Client Components are also rendered on the server for the first HTML and then hydrated, so you still get server-rendered output. What changes is that their code is sent to the browser, which is why you should keep the boundary as low in the tree as you can.

Can I pass Server Actions as props to Client Components?

Yes. A function marked with 'use server' can be passed to a Client Component, and I tested this with an imported action, an inline action and a prop with an on name. Use it for forms and mutations, and remember that the action is reachable from outside, so it must check permissions and validate its input.

Why does Next.js allow strings and numbers as props, but not functions?

Props that cross the boundary have to be written into the payload and rebuilt in the browser. Strings, numbers and plain objects are data, so they survive that trip. A function is code with captured variables that belong to the server, and the browser cannot run it. Server Actions are the exception, because they are not sent as code: they are sent as a reference that the browser uses to call the server.