Is it good to use server actions for form intensive app?
Unanswered
Gulf menhaden posted this in #help-forum
Gulf menhadenOP
I'm thinking of using
But when I'm thinking on ways to test my business logic, it seems that
In comparison, what I can do in
server actions instead of api routes for retrieving and mutating data.But when I'm thinking on ways to test my business logic, it seems that
server actions is not ideal since, I cannot isolate the server actions apart from the UI, and test them accordingly.In comparison, what I can do in
api routes is to create a postman collection and test each api routes if they are mutating and retrieving the data properly.6 Replies
Holland Lop
@Gulf menhaden did you get an answer yet?
i have the exact problem
The answer to this question highly depends on your needs and requirements. Both server actions and api routes have their pros and cons.
Server Actions:
- Faster to implement
- Built-in CSRF
- Very difficult to isolate
- Provides some features that integrate with newer RSC features nicely.
API Routes:
- Slower to implement
- Isolated logic
- You'll likely need this if you plan to add mobile / desktop app support with the same features
Server Actions:
- Faster to implement
- Built-in CSRF
- Very difficult to isolate
- Provides some features that integrate with newer RSC features nicely.
API Routes:
- Slower to implement
- Isolated logic
- You'll likely need this if you plan to add mobile / desktop app support with the same features
I have a form intensive app and I am using server actions only because they are faster to implement. Also, I am trying to make use of the newer RSC features as much as possible
Though at the end of the day, you just create a function with all the core logic and then import it to a server action or API route
Chinese perch
True, cant use something like postman, but you could unit test them like a rgular function pretty easily, right? (I have not tried this myself yet)