Broader Frontends
Author : Kazuhiro Hara
Article permalink

What React 19 RC Actions Exchange over POST

Since around last month, I have been checking behavior and specifications around React 19 RC for work. In the middle of that, I later noticed this sentence in the form-related documentation.

> "When a function is passed to action or formAction, the HTTP method will be POST regardless of the value of method."

With Actions, you can implement the conventional Ajax-like approach using useActionState through the action attribute of the form element.

Besides that, it is also possible to use server actions to run server-side processing.

However, I had missed the earlier point: "When a function is passed to action or formAction, the HTTP method will be POST regardless of the value of method." Something fairly important is written quite casually there. So if the HTTP method is automatically decided as POST, what values are actually exchanged?

If you use Next.js 15.0.0-rc.0, you can try it right away.

For example, what happens if you specify a pure server function as action, instead of building it like a fetch request, and have it return some object? Something like this.

'use server'

export async function testAction(name: string) {
  const result = { id: "1", name: name, message: "message" };
  return result;
}

My rough expectation was that the argument would be passed as a request parameter, and the return value would come back as JSON.

But that is not what actually happens.

When I checked in Chrome DevTools, the payload was [""]. In other words, it is passed as an array of arguments. The response returns something like this, for example.

0:["$@1",["development",null]]
1:{"id":"1","name":"<Name value>","message":"message"}

If you have used React Server Components and have looked at the values exchanged for server-side components, you might recognize this type of format.

This feeling that the exchange is not JSON-based is probably efficient, but it is so proprietary that I do get a little worried about whether it will be okay in the future. Still, the structure may change going forward, so I plan to keep using it for a while and understand its pros and cons.

Next.jsNode.jsReact

Share