| 1 | "use server"; |
| 2 | |
| 3 | import { readMessage } from "./env.ts"; |
| 4 | |
| 5 | /** |
| 6 | * A React server function driven by `useActionState` in a client component: |
| 7 | * the form submission POSTs to the RSC endpoint and executes here, inside the |
| 8 | * worker runtime — reading the `MESSAGE` binding proves it. |
| 9 | */ |
| 10 | export async function greet( |
| 11 | _previous: string, |
| 12 | formData: FormData, |
| 13 | ): Promise<string> { |
| 14 | const name = String(formData.get("name") ?? "anonymous"); |
| 15 | return `Hello, ${name}! MESSAGE=${await readMessage()}`; |
| 16 | } |