1import { getCloudflareContext } from "@opennextjs/cloudflare";
2import { signGuestbook } from "./actions.js";
3
4// Server-action mutation path: the form posts to the action, which writes
5// to KV; this force-dynamic page reads the latest entry back on render.
6export const dynamic = "force-dynamic";
7
8export default async function Guestbook() {
9 const { env } = getCloudflareContext();
10 const latest = await env.FIXTURE_KV.get("guestbook:latest");
11 return (
12 <main>
13 <h1>GUESTBOOK_MARKER</h1>
14 <p>guestbook-latest:{latest ?? "empty"}</p>
15 <form action={signGuestbook}>
16 <input type="text" name="name" placeholder="name" />
17 <button type="submit">Sign</button>
18 </form>
19 </main>
20 );
21}