Integrations
Next.js + server actions
Use FormsDock as the validation layer behind a server action.
7 min read
FormsDock works as the authoritative spam check behind a Next.js server action. Your action stays type-safe; the network call happens server-to-server.
typescript
"use server";
import { redirect } from "next/navigation";
export async function submitContact(formData: FormData) {
const res = await fetch("https://api.formdock.dev/v1/submit", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.FORMSDOCK_KEY}`,
},
body: formData,
});
if (!res.ok) {
return { ok: false, error: "submission_failed" };
}
redirect("/thanks");
}