You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let libraries mark wrapper calls that survive the "use server" client transform
#5214
I'm not sure if this is a good idea or not but something I was playing around with. It kinda hides the true intention but maybe worth sacrificing for the DX?
The problem
In a module-level "use server" file, each export's value is registered as a server function and the client gets a bare RPC stub. That means you can't co-locate router wrappers with the server code they wrap:
On the client, getTodos becomes createServerReference("getTodos-…"). The query() wrapper is gone, so there's no client cache and no .key, and formAction loses its form handling. Today the workaround is two files: server functions in one, query(fn, 'todos') in another.
Proposal
Add a compiler option that lists wrapper calls to re-apply around the generated stub, so the compiler stays router-agnostic:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I'm not sure if this is a good idea or not but something I was playing around with. It kinda hides the true intention but maybe worth sacrificing for the DX?
The problem
In a module-level "use server" file, each export's value is registered as a server function and the client gets a bare RPC stub. That means you can't co-locate router wrappers with the server code they wrap:
On the client, getTodos becomes createServerReference("getTodos-…"). The query() wrapper is gone, so there's no client cache and no .key, and formAction loses its form handling. Today the workaround is two files: server functions in one, query(fn, 'todos') in another.
Proposal
Add a compiler option that lists wrapper calls to re-apply around the generated stub, so the compiler stays router-agnostic:
All reactions