{"id":157,"hash":"66dd2a0085087a2772f3a62218c6f72a36918720eefe804849709095ea57b245","pattern":"Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with &quot;use server&quot;","full_message":"Got this error message in Next.js but have no idea what to do with this. Next.js version 13.0.5.\n\nI was passing a prop to a client component in Next.js. Prop is the list of objects, and one of the values is a function. But the question is, what this error message means?\n\nError: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with \"use server\"\n\nHow can I expose a function by marking it with \"use server\"?\n\nmatchesColumns.push({ field: 'pk', headerName: \"\", flex: 0.3, renderCell: (params, event) => (<Link href={`/matches/${encodeURIComponent(params.row.pk)}`}>Details</Link>) });\n(...)\n{<Tabela2 rows={matchesRows} columns={matchesColumns}/>}","ecosystem":"npm","package_name":"reactjs","package_version":null,"solution":"This is a new upcoming Next.js feature called server actions.\n\nYou can use server actions to pass async functions from server to client components while having them still be callable from client.\n\nHere's an example:\n\n// page.tsx\n\n\"use server\";\n\nimport { ClientComponent } from './ClientComponent.tsx';\n\nasync function deleteItem(itemId: string) {\n  \"use server\"; // mark function as a server action (fixes the error)\n\n  // TODO add item deletion logic\n  return null;\n}\n\nexport function Page() {\n  return <ClientComponent deleteItem={deleteItem} />\n}\n\n// ClientComponent.tsx\n\nexport function ClientComponent({ deleteItem }) {\n  return (\n    <button onClick={async () => {\n      await deleteItem(\"foobar\");\n      alert(\"item has been deleted\");\n    }}>\n      delete item\n    </button>\n  );\n}","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/75676177/error-functions-cannot-be-passed-directly-to-client-components-unless-you-expli","votes":69,"created_at":"2026-04-19T04:41:25.074407+00:00","updated_at":"2026-04-19T04:51:06.846365+00:00"}