Server Actions ("use server")
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Server Actions janë funksione async me "use server" që ekzekutohen në server, por i thërret direkt nga një formular ose buton në React — pa shkruar vetë një API endpoint.
EnglishEN
Server Actions are async functions marked "use server" that run on the server, but you call them straight from a form or button in React — without writing an API endpoint yourself.
Si ta mendosh
Si një zile në tavolinë që thërret drejtpërdrejt kuzhinën.
Lexoje në anglisht
Like a bell on your table that calls the kitchen directly.
Shembull kodijsx
async function ruajNoten(formData) {
"use server";
await db.nota.create({ vlera: Number(formData.get("nota")) });
}
<form action={ruajNoten}><input name="nota" /><button>Ruaj</button></form>