I have started developing an internal task management system based on server actions. The problem is that server actions cannot run in parallel. At some screens using Parallel routes, I am calling more than one server action, and since they run sequentially, it’s hurting performance.
What would be the best course of action here, I found a library that can be used to run server action in parallel While I was reading somewhere that one should not use server actions for GET requests and only for mutations, based on this I am thinking about going to ‘api’ based routes for GET requests and keep the post requests as server actions. Need advice from seniors here who have worked in NextJs before.
Also having a codebase following two kinds of approaches server action and API routes seems weird to me because as per my limited knowledge plus what Alex taught in his Code Quality Course, one should follow one pattern in a codebase so that it stays consistent. Would appreciate the help or any kind of advice here.
Just to preface, we build the Taro webapp using Next.js, but we don't use server actions. Not that it was intentional, it just ended up working out that way. It was experimental with the Next.js version that we were using. I haven't personally used server actions before, so it might be useful to get some input from someone else that has used them before, too.
What would be the best course of action here, I found a library that can be used to run server action in parallel While I was reading somewhere that one should not use server actions for GET requests and only for mutations
Once again, I've only read about server actions. It sounds like they should only be used for mutating data. I am really hesitant about using libraries in a way that they weren't meant to be used.
If I was building a new webapp, I would probably still use a REST API (at least for an enterprise app) because it's tried and true:
one should follow one pattern in a codebase so that it stays consistent. Would appreciate the help or any kind of advice here.
You can try to use the library to allow data fetching to keep everything consistent but just know that there are tradeoffs. It just seems very "code-smelly" to be using a hack to get server actions to work in a way that it wasn't meant to work. You might be able to get it to work now, but it's always hard to tell whether this will cascade into more hacks in the future. And, it makes it harder to migrate off of in the future.
I think if your app is going to remain lightweight for the future, you can go with the server action path. At least you'll know if you go down this path, it will be easier to migrate later if you need to. But, if you're expecting to build a platform for many clients in the future, it might be worth it to go the REST API route now.
Yes actually this app is for our internal management purposes plus for clients who will be working with us ( kind of a Management System ) and since I am early in the process ( making an MVP ) I want to make sure it's scalable in the future.