Next.js App Router: quand utiliser un Server Action vs une Route Handler ?
asked 9 days ago201 viewsfr
Pour muter des données, je ne sais jamais s'il faut une Server Action ou un route.ts. Quels sont les critères de décision (revalidation, clients externes, sécurité) ?
🤖 AI diagnosis
AI-generated. Not an answer — the community below confirms or corrects it. Always verify before relying on it.
3 Answers
Use a partial unique index that ignores soft-deleted rows:
CREATE UNIQUE INDEX users_email_active
ON users (email) WHERE deleted_at IS NULL;
Now soft-deleted rows don't collide with new ones.
Sign in to tell others whether this worked.
Prefer a system-assigned managed identity — no secrets to rotate, lifecycle tied to the resource. Use a service principal only when the identity must be shared across resources or used from outside Azure.
Sign in to tell others whether this worked.
Server Action for form mutations tied to your own DB and revalidation; Route Handler when you need a stable HTTP endpoint (webhooks, external/mobile clients, non-React consumers). Both must re-validate auth server-side.
Sign in to tell others whether this worked.
Sign in and verify your email to post an answer.