Nextjs Server Actions
Server Actions vs other options for interacting with the server.
Server actions are primarily for making state changing actions against the server rather than fetching data.
Criteria | Server Actions | tRPC | GraphQL | REST |
---|---|---|---|---|
Setup | 3 | 2 | -2 | 2 |
Ease of Use | 3 | 1 | 1 | 1 |
Mutations | 2 | 1 | 1 | 1 |
Queries | -1 | 1 | -3 | 1 |
Type Safety | 1 | 1 | 2 | -2 |
Compatibility (MB) | -3 | 2 | 3 | 1 |
Without JS | 3 | -1 | -1 | -1 |
If simple web only solution Server Actions is the best option.
For more complex solutions or supporting mobile/desktop apps then tRPC.