01 Client form
The usual Next.js path is a client component that POSTs FormData to Furrow. No /api/contact route, no mail library, no server. This works for the App Router, a static export, and the edge runtime, because the browser talks to Furrow.
Replace fp_k7m2 with the real public key. Do not move it into NEXT_PUBLIC_ or .env — it is not a secret, and a missing variable is how these forms break in production.
Add the site’s apex, www, and localhost to the project’s allowed domains. Browser fetch is CORS-checked against that list; anything else is 403 forbidden_origin.
components/contact-form.tsx
'use client';
import { useState } from 'react';
const ENDPOINT = 'https://api.furrowforms.com/s/fp_k7m2';
export function ContactForm() {
const [sent, setSent] = useState(false);
const [loadedAt] = useState(() => Date.now());
async function submit(formData: FormData) {
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: { Accept: 'application/json' },
body: formData,
});
const data = await res.json();
setSent(Boolean(data.ok));
}
if (sent) return <p>Thanks — we’ll be in touch.</p>;
return (
<form action={submit}>
<input type="text" name="_gotcha" style={{ display: 'none' }} tabIndex={-1} autoComplete="off" />
<input type="hidden" name="_ft" value={loadedAt} />
<input name="name" type="text" required />
<input name="email" type="email" required />
<textarea name="message" required />
<button>Send</button>
</form>
);
}
Accept: application/json is what selects the JSON response. Without it, a classic POST is a 303 redirect.
02 App Router server action
A server action is the right shape when the submit should stay on your origin — extra checks, a redirect you control, or a file you want to forward yourself. The action still POSTs to the same Furrow URL. Furrow has no separate server-side endpoint.
A server fetch has no browser Origin. If the project has allowed domains, send an Origin header that matches one of them or Furrow answers 403 forbidden_origin. Use the production origin in production and add localhost while you test.
Copy only the fields you defined. A server-action FormData also carries Next.js action bookkeeping fields, and those should not land in the submission.
app/contact/actions.ts
'use server';
import { redirect } from 'next/navigation';
const ENDPOINT = 'https://api.furrowforms.com/s/fp_k7m2';
const SITE_ORIGIN = 'https://example.com';
export async function sendContact(formData: FormData) {
const body = new FormData();
for (const key of ['name', 'email', 'message', '_gotcha', '_ft', 'cf-turnstile-response']) {
const value = formData.get(key);
if (typeof value === 'string') body.append(key, value);
}
const file = formData.get('attachment');
if (file instanceof File && file.size > 0) body.append('attachment', file);
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: {
Accept: 'application/json',
Origin: SITE_ORIGIN,
},
body,
});
const data = await res.json().catch(() => null);
if (!res.ok || !data?.ok) {
throw new Error('Form submission failed');
}
redirect('/thanks');
}
redirect() throws, so call it only after a successful JSON body. Failure throws and the App Router error boundary takes over.
03 Route handler
Same proxy, as a route handler, if an existing client already POSTs to /api/contact. Forward the multipart body and pass the incoming Origin through so the allowlist still sees the real site.
app/api/contact/route.ts
import { NextResponse } from 'next/server';
const ENDPOINT = 'https://api.furrowforms.com/s/fp_k7m2';
export async function POST(request: Request) {
const incoming = await request.formData();
const origin = request.headers.get('origin') ?? new URL(request.url).origin;
const res = await fetch(ENDPOINT, {
method: 'POST',
headers: {
Accept: 'application/json',
Origin: origin,
},
body: incoming,
});
const data = await res.json().catch(() => ({ ok: false }));
return NextResponse.json(data, { status: res.ok ? 200 : res.status });
}
04 Spam protection
Honeypot field _gotcha, kept hidden and empty. Timing field _ft, set to Date.now() when the form renders; omitting it is not penalized, but browser forms should send it. Optional Cloudflare Turnstile: the site key and secret live on the Furrow project. When require_turnstile is true, get_snippet includes the widget, which posts the reserved field cf-turnstile-response. Do not put the Turnstile secret in the Next.js app.
Domain allowlist, per-IP per-form rate limit (default 10 requests / 60 seconds), and server-side filtering are project settings. Caught spam returns a normal 200 and is quarantined: no normal notification, no webhook, no quota. A [Potential spam] email still goes to notify addresses so a real lead is not dropped quietly.
05 Success and redirect
A classic form action pointed at the Furrow URL — no React state — gets a 303 to default_redirect_url. That thank-you URL is absolute and on an allowed domain. Build the page in the Next.js app.
fetch() and the server action above send Accept: application/json and read { "ok": true, "id": "<submission_id>" }. The client form swaps in a thank-you message. The server action calls redirect("/thanks") itself. Either way the visitor should see a confirmation, not a JSON payload.
components/contact-form.tsx
export function ContactForm() {
return (
<form action="https://api.furrowforms.com/s/fp_k7m2" method="POST">
<input type="text" name="_gotcha" style={{ display: 'none' }} tabIndex={-1} autoComplete="off" />
<input type="hidden" name="_ft" value="" />
<input name="email" type="email" required />
<textarea name="message" required />
<button>Send</button>
</form>
);
}
No JavaScript success state. The browser follows Furrow’s 303.
06 File uploads
Uploads are off until you enable them on the project. Every form on that website inherits the switch. Send multipart FormData from a file input — JSON cannot carry files. Default types: PDF, JPEG, PNG, WebP. Multi-file fields use a [] name, name="photos[]".
Files are stored in a private per-project inbox. Emails and webhooks link to the inbox. They do not include a public file URL. The server action above already forwards a single attachment field; the client form only needs the input.
components/contact-form.tsx
<input
name="attachment"
type="file"
accept="application/pdf,image/jpeg,image/png,image/webp"
/>
07 Set it up with an agent (MCP)
Paste “Fetch furrowforms.com/ai and set up a contact form backend for my Next.js app.” The agent can register the account (you read one 6-digit email code), then call bootstrap_site. That one call creates the client, the website, and the forms. It is idempotent by slug, so re-running it does not duplicate them.
get_snippet returns Next.js code for the field contract, including _gotcha, _ft, and the Turnstile widget when the project requires it. test_webhook checks a signed delivery. The MCP endpoint is https://api.furrowforms.com/mcp, and the same operations exist over REST. Both work on the free tier. The frw_ token stays in the MCP client, not in the app’s env.