Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: Server functions work on event handler props in Server Components; is this intended? | GoodFirstPicks

Bug: Server functions work on event handler props in Server Components; is this intended?

facebook/react 2 comments 17d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeReactJavaScriptTypeScript

Why this is a good first issue

Investigating whether server functions in event handlers is intended behavior

AI Summary

The issue questions whether server functions working in event handler props is intended behavior, showing inconsistent results across frameworks. Needs investigation into React's design intentions and potential documentation updates.

Issue Description

Server functions work on event handler props in Server Components — is this intended?

This isn't a bug report - the behaviour described below works correctly. I'm raising this to ask whether it's intended/stable behaviour and whether it should be documented.

React version: 19

Steps To Reproduce

  1. Create a Server Component (no "use client" directive)
  2. Define a server function ("use server") inside it
  3. Pass the server function directly to an event handler prop on a native element (e.g., onClick, onMouseEnter)
  4. Trigger the event — it sends a POST request to the server and executes the function

Link to code example:

// This is a Server Component (no "use client" directive)
export default function Page() {
  async function handleClick() {
    "use server";
    console.log("click");
  }
 
  async function handleHover() {
    "use server";
    console.log("hovering...");
  }
 
  return (
    <div>
      <button onClick={handleClick}>Click me</button>
      <h2 onMouseEnter={handleHover}>Hover me</h2>
    </div>
  );
}

Note: Passing the event object to the server function (e.g., onClick={(e) => handleClick(e)}) errors out, presumably because the event cannot be serialized. The bare function reference works fine.

Tested across

FrameworkReactResult
Next.js 1619✅ Works
Next.js 15.5.919✅ Works
Next.js 14.2.3518❌ Crashes: "Only plain objects, and a few built-ins, can be passed to Server Actions"
Waku19✅ Works (independently confirmed)

The fact that this works on both Next.js and Waku suggests it's a React-level behavio

GitHub Labels

Status: Unconfirmed

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • behavior may be intentional
  • cross-framework implications
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno