Next.js: Functions cannot be passed to Client Components
A function prop cannot cross into a Client Component unless it is a server action. Move the handler, mark it use server, or pass data instead.

Introduction & Quick Summary
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.
{prop: "onClick", value: function handleSelect() {}}A Server Component and a Client Component do not share a JavaScript heap. The props you pass from server to client are serialized into the RSC payload, and a function has no serialized form unless React knows it is a server reference. This error is the boundary rejecting the prop, not a hook or a rendering problem.
The three legitimate answers:
- The function is a user interaction — move it into the Client Component and keep the server component free of handlers.
- The function must run on the server — mark it
"use server". It becomes a server action, a reference the client can call. - The function is only formatting or lookup logic — pass data instead of the function: a preformatted string, an enum-like key, or a plain map the client can switch on.
Or maybe you meant to call this function rather than return it is a separate, common cause: onClick={handleClick()} passes the return value of the call, which is often a function. Remove the parentheses.
| Failure | What is passed | Fix |
|---|---|---|
onClick from a server file | Plain function | Move handler into the client component |
onClick={handle()} | Return value, often a function | Call only inside the handler |
| Server mutation | async function not marked | "use server" directive |
| Formatter/deps injection | Helper function | Pass data, switch on a key |
Context provider value with callbacks | Function in an object | Keep provider + state in one client file |
| Library component | onChange default handler | Wrap it in your own client wrapper |
Core Mechanics, Signatures & Reproducible Setup
The server renders a Server Component to a serialized tree. Every prop crossing into a Client Component must fit React's serialization format:
- primitives:
string,number,bigint,boolean,undefined,null - plain objects with no prototype beyond
Object, arrays and iterables of serializable values Date,Map,Set,FormData,ArrayBuffer, typed arrays- promises resolved in a
use()boundary - plain JSX elements already created on the server
- server actions (functions marked
"use server") and globally registered symbols
Class instances, functions without the directive, and symbols created outside Symbol.for are not serializable and fail here.
Reproduction:
// app/products/page.tsx (Server Component)
import { FilterBar } from "./filter-bar";
export default async function Page() {
const products = await db.product.findMany();
const onFilter = (q: string) => console.log(q); // plain closure
return <FilterBar products={products} onFilter={onFilter} />;
}// app/products/filter-bar.tsx
"use client";
export function FilterBar({ products, onFilter }: {
products: { id: string; name: string }[];
onFilter: (q: string) => void;
}) {
return <input onChange={(e) => onFilter(e.target.value)} />;
}The server component compiles; the request fails at render. The server-action variant runs:
// app/actions.ts
"use server";
export async function logFilter(q: string) {
await db.filterEvent.create({ data: { q } });
}// app/products/page.tsx
import { logFilter } from "@/app/actions";
return <FilterBar products={products} onFilter={logFilter} />;A server action is callable from the client, but it is a network call, not a local function: it cannot close over server-only state, its arguments must be serializable, and it always returns a promise.
Key Comparison Table
| Pattern | Function crosses the boundary | Network round trip | Use when |
|---|---|---|---|
| Handler inside client component | No | No | Pure UI interaction |
"use server" action | Yes, as a reference | Yes | Mutation, form submit |
Server action with .bind(null, id) | Yes, bound args serialized | Yes | Per-row actions |
| Pass data, switch on key | No | No | Formatting, labels, sort modes |
children prop of rendered JSX | No | No | Wrapping a client layout |
| Context provider in client file | No, stays client-side | No | Shared interactive state |
| Prop value | Serializable | Error if passed |
|---|---|---|
"asc", 42, true, null | Yes | — |
{ sort: "asc", tags: ["a"] } | Yes | — |
new Date(), new Map() | Yes | — |
() => {} in a server file | No | This error |
async () => {} with "use server" | Yes | — |
new PrismaClient() / class instance | No | "Only plain objects..." variant |
Symbol("x") | No | Serialization error |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
Case 1: Keep the interaction client-side
// app/inbox/page.tsx — Server Component
import { InboxList } from "./inbox-list";
export default async function Page() {
const messages = await db.message.findMany({ orderBy: { at: "desc" } });
return <InboxList messages={messages} />; // data only
}// app/inbox/inbox-list.tsx
"use client";
import { useState } from "react";
export function InboxList({ messages }: { messages: { id: string; subject: string }[] }) {
const [selected, setSelected] = useState<string | null>(null);
return (
<ul>
{messages.map((m) => (
<li key={m.id} aria-selected={m.id === selected}>
<button onClick={() => setSelected(m.id)}>{m.subject}</button>
</li>
))}
</ul>
);
}This is the default fix and it removes a network hop: push state down to the smallest component that interacts, and keep the data fetch on the server.
Case 2: Per-row server actions with bound arguments
// app/inbox/row-actions.tsx
import { archive } from "@/app/actions";
export function RowActions({ id }: { id: string }) {
return (
<form action={archive.bind(null, id)}>
<button type="submit">Archive</button>
</form>
);
}<form action={archive}>
<input type="hidden" name="id" value={id} />
<button type="submit">Archive</button>
</form>Bound arguments are captured in the payload, so prefer the hidden input when the id is already available.
Case 3: "Only plain objects" — a class instance behind the same error
// server
const invoice = await prisma.invoice.findUniqueOrThrow({ where: { id } });
return <InvoiceView invoice={invoice} />; // Decimal, Date, class instancesPrisma's Decimal and ORM entities carry prototypes and methods. Map explicitly:
const invoice = await prisma.invoice.findUniqueOrThrow({ where: { id } });
const view = {
id: invoice.id,
total: invoice.total.toString(),
issuedAt: invoice.issuedAt.toISOString(),
};
return <InvoiceView invoice={view} />;The client receives plain data and formats for display.
Case 4: A context provider that holds callbacks
// app/layout.tsx — Server Component
import { ToastProvider } from "./toast";
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<ToastProvider onDismiss={(id) => console.log(id)}>
{children}
</ToastProvider>
);
}The provider is a Client Component, so onDismiss is an unserializable prop. Move the callback inside the provider file and expose a stable API:
// app/toast.tsx
"use client";
import { createContext, useContext, useState } from "react";
const ToastCtx = createContext<{ push: (m: string) => void } | null>(null);
export function ToastProvider({ children }: { children: React.ReactNode }) {
const [items, setItems] = useState<string[]>([]);
const push = (m: string) => setItems((s) => [...s, m]);
return (
<ToastCtx.Provider value={{ push }}>
{children}
{items.map((m, i) => <p key={i}>{m}</p>)}
</ToastCtx.Provider>
);
}Case 5: Passing a formatter by name instead of by value
// server
<Price amount={1999} format={(n) => `$${(n / 100).toFixed(2)}`} /> // error// client
const FORMATTERS = {
usd: (n: number) => `$${(n / 100).toFixed(2)}`,
} as const;
export function Price({ amount, currency }: { amount: number; currency: keyof typeof FORMATTERS }) {
return <span>{FORMATTERS[currency](amount)}</span>;
}Formatting on the client also avoids hydration mismatches.
Common Compilation/Runtime Mistakes & Version Gotchas
"use server"in a Client Component file. The directive must be at the top of an async server file or an async function inside a Server Component. Placing it in a"use client"file is a build error.- Server actions must be async. A synchronous function marked
"use server"fails at build time; the client always gets a promise. - Arguments are serialized too. A server action that takes a
Dateis fine; one that takes a class instance or another function is not. - A parenthesized handler.
onClick={save()}passes the return value of the call, which for a curried factory or a resolver is a function built on the server. Remove the parentheses. "use server"does not make closures work. A server action cannot read the enclosing request'scookies()unless it callscookies()itself; state captured at module scope is shared by all requests.- Turbopack messages. The Turbopack builder reports the same defect as
Only plain objects, and a few built-ins, can be passed to Client Components from Server Components, naming the offending prop path. - Memoized callbacks are still functions.
useCallbackresults cannot cross the boundary; moving the hook into the client component is the only fix.
Inspect the failing prop payload by logging the object and formatting it with the JSON formatter; the serializer's own message names the path, and the diff tool helps confirm a prop was removed in a refactor. For the HTTP layer around a server action, the curl builder reproduces the POST that Next.js sends.
Primary references: "use client" defines which values can cross the server-client boundary, and Server and Client Components covers the composition patterns allowed in the App Router.
Official references
primary documentationThe Next.js documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Next.js work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Next.js guides
All Next.js guidesModule not found: Can't resolve a package or alias in Next.js
TypeScript and the bundler resolve imports separately. Align path aliases, workspace dependencies, exports conditions and filename case.
Next.js 16 DynamicServerError: cookies(), headers() and fetchCache
Request-time APIs make a route dynamic, and Next 16 replaced the segment configs with Suspense boundaries and use cache. What to delete and what to wrap.
Next.js cacheComponents: 'used uncached or runtime data' build error
Cache Components makes the build refuse to guess where the static shell ends. Stream it, cache it with use cache, or declare the route blocking.
next/font: Failed to fetch a Google font during the build
The font is fetched during the build, not at runtime. Vendor it with next/font/local or give CI and Docker a route out.
More in Next.js
All Next.js guidesThe guides filed next to this one in Next.js, in library order.