1"use server";
2
3import { getCloudflareContext } from "@opennextjs/cloudflare";
4import { revalidatePath } from "next/cache";
5
6// Server action: writes the entry into the FIXTURE_KV binding via
7// getCloudflareContext, then revalidates the page so the next render
8// (force-dynamic anyway) reflects it.
9export async function signGuestbook(formData) {
10 const name = formData.get("name");
11 if (typeof name !== "string" || name.length === 0) return;
12 const { env } = getCloudflareContext();
13 await env.FIXTURE_KV.put("guestbook:latest", name);
14 revalidatePath("/guestbook");
15}