Skip to content

Commit 14fa12a

Browse files
add server actions implementation plan (#2166)
1 parent edf2983 commit 14fa12a

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Server Functions Initial Implementation Plan
2+
3+
## Definition
4+
5+
Server Functions allow Client Components to call async functions executed on the server.
6+
7+
## Other Frameworks Implementation Way
8+
9+
### Next.js
10+
11+
Next.js framework re-render the whole app when a server action is executed, so all server components re-render and get latest server state.
12+
13+
### Waku
14+
15+
It executes the server function without re-rendering the app.
16+
17+
### React Implementation Sample
18+
19+
- Exists at [flight example on react repo](https://github.com/facebook/react/tree/main/fixtures/flight)
20+
- Rerenders the whole app on server action execution
21+
22+
## Implementation Steps
23+
24+
1. Add support for registering server actions and transforming rsc and client bundles at `react-on-rails-rsc` webpack loader. Seems that the webpack loader currently doesn't transform the server functions on the client bundle. However, the react node loader at React repo seems that it looks for the `"user server"` directive and transform the server functions. Debug to find out why the server functions are not transformed inside react on rails pro dummy app client bundle.
25+
1. Implement `callServer` function on client side that generates the server action id, encodes the server action arguments and send them to the back-end.
26+
1. Implement backend endpoint to receive the server action requests, decode it, execute and return the result. You need to decide if the whole app should be rendered or not.
27+
1. Ensure progressive enhancement of the form works (when the page is not hydrated yet, form actions can still be submitted).

0 commit comments

Comments
 (0)