Next.js
Two patterns for the App Router: a client component that posts from the browser, and a Server Action that submits with a server key. Hosts, IDs, and keys below are placeholders.
Never put a FormRoost server key in a NEXT_PUBLIC_ variable. Next.js inlines those into the browser bundle, where anyone can read them. Only the public submission URL may be public.
Client component
Add your dev origin, such as http://localhost:3000, to Allowed origins on the form. The browser sends Origin; no key is involved.
Errors are RFC 9457 application/problem+json. Branch on code; see errors.
Server Action
The action runs on your server, reads a key that never reaches the browser, and sends an Idempotency-Key so a retried submit is stored once. Rotate the key after a confirmed 201, and keep the same key and field values if a submission fails so the visitor can retry without retyping.
Server requests omit Origin, so production requires the bearer key. FormRoost's per-network rate limit sees your server rather than the visitor, so add your own limits in front of the action. The same code works in a Route Handler (app/api/contact/route.ts) if you prefer an HTTP endpoint. See server submissions and API keys.
Go to production
Add your live HTTPS origin, publish the configuration, change sandbox to production in both URLs, and use a production key.