As I learned by doing: NextJS Server Actions are synchronous.
I want to achieve concurrency; and I like the syntax of having this abstracted; therefore I've created a NextJS API endpoint that has the following syntax:
import { handleError } form '@/lib/utils';
import { z } from 'zod';
const schema = z.object({ .. }); // some random unrelated zod schema
export async function POST(req: Request) {
try {
const myArgs = schema.parse(await req.json());
const data = await myServerAction(myArgs);
return Response.json({ data }, { status: 200 });
} catch (error) {
return handleError(error, req);
}
However, I'm not entirely positive this runs concurrently.
Is there anybody that can confidently say/prove that this is indeed concurrent and not synchronous as the Server Actions are?
myServerAction
? Any external API? If not, then it shouldn't be concurrent.