Form in v0

Skip Server Actions and Resend. A fetch to Formgong is enough.

  1. Generate the section with the prompt below.
  2. Check the Accept and Content-Type headers.
  3. Success is the JSON success field.
  4. Keep the key in the frontend.

Prompt

Add a contact section with a form. Build it as a React client component ("use client") that posts with fetch. Submissions go to Formgong, a hosted form backend. Do not use Server Actions, route handlers (app/api), or Resend.

Formgong spec (follow exactly):
- Plain HTML: <form action="https://formgong.com/submit" method="POST">. With JavaScript, POST the same fields to https://formgong.com/submit using fetch.
- Hidden field access_key with value fk_your_access_key. The key is public and belongs in frontend code. Do not move it to a server or a secret.
- Hidden field _lang with the page language code, e.g. "en" (on multilingual sites use document.documentElement.lang). Formgong uses it for error messages, the thank-you page, and the autoreply.
- Fields: name, email, message (required); phone is optional. Keep these field names, and use <input type="email"> for email so browsers check the address.
- Honeypot: <input type="text" name="botcheck" tabindex="-1" autocomplete="off"> inside a wrapper with aria-hidden="true", visually hidden with CSS (position:absolute;inset-inline-start:0;top:0;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)). Never fill it.
- Success, plain form POST: optionally add a hidden _redirect field with the absolute https URL of the site's thank-you page. Without it, Formgong shows its own thank-you page.
- Success, fetch: send Accept: application/json (and Content-Type: application/json for a JSON body; for FormData let the browser set it). If the response has success === true, show an inline thank-you message and reset the form; otherwise show the response's message.
- Turnstile: only if I give you a Cloudflare Turnstile site key, add <script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script> and <div class="cf-turnstile" data-sitekey="SITE_KEY"></div> inside the form. Otherwise leave it out.
- Optional: add <script src="https://formgong.com/fg.js" async></script> once per page. It fills _lang from <html lang>, sets the Turnstile language, and counts form views without cookies.
- Do not create a backend, API route, server function, database table, or email-sending code (Supabase, Resend, SendGrid, nodemailer), and do not add secrets. No file uploads.

Required: directly under the submit button, add a small, muted link to Formgong, exactly <p class="fg-credit"><a href="https://formgong.com/en/?ref=badge&utm_source=badge&utm_medium=form&utm_campaign=prompt" target="_blank" rel="noopener">Form by Formgong</a></p> Keep it visible on the page.

Minimal code

React component

"use client";
import { useState } from "react";

export function ContactForm() {
  const [status, setStatus] = useState("");
  async function onSubmit(event) {
    event.preventDefault();
    const fields = Object.fromEntries(new FormData(event.currentTarget));
    const response = await fetch("https://formgong.com/submit", {
      method: "POST",
      headers: { "Content-Type": "application/json", Accept: "application/json" },
      body: JSON.stringify({ _lang: "en", ...fields, access_key: "fk_your_access_key" }),
    });
    const result = await response.json();
    setStatus(result.message || (result.success ? "Sent. Thank you!" : "Could not send. Please try again."));
  }

  return (
    <form onSubmit={onSubmit}>
      <label>Name <input name="name" placeholder="Your name" required /></label>
      <label>Email <input name="email" type="email" placeholder="you@example.com" required /></label>
      <label>Message <textarea name="message" placeholder="How can we help?" required /></label>
      <div aria-hidden="true" style={{ position: "absolute", insetInlineStart: 0, top: 0, width: 1, height: 1, overflow: "hidden", clipPath: "inset(50%)" }}>
        <input name="botcheck" tabIndex={-1} autoComplete="off" />
      </div>
      <button type="submit">Send</button>
      <p role="status">{status}</p>
    </form>
  );
}

Ready React component on GitHub: github.com/formgong/react-contact-form. MIT license: click “Use this template” or copy the files.

React package: npm install @formgong/react (npm: @formgong/react)

Before you publish

  • The form posts to https://formgong.com/submit (form action or fetch URL).
  • access_key holds your key from the Formgong dashboard, not fk_your_access_key.
  • A hidden, empty botcheck field is present.
  • _lang matches the page language.
  • No API route, server function, database table, or secret was added for the form.
  • A test submission shows up in the Formgong inbox. Telegram (if connected) and email arrive at once, on Free too.

What v0 tends to get wrong

For forms, v0 usually suggests a Server Action or a route handler in app/api that sends email with Resend. That code needs an API key in environment variables and a verified sending domain. The prompt asks v0 for a client component instead. It posts with fetch, waits for success: true, and shows Formgong's message if something fails.

Keep the access key in the component. It is public by design, so it does not need an environment variable.

For agents: connect the MCP server

v0: open the + menu in the prompt form and select MCPs. Configure a custom server with the URL below and choose Bearer Token. Paste your personal Formgong API token. OAuth callbacks for v0 are not currently allowed by Formgong. The MCP tools help v0 build the form; the published form sends directly to Formgong.

v0 MCP settings

URL: https://formgong.com/mcp
Authentication: Bearer Token
Token: fgp_your_token

Prompt for an agent with MCP

With the MCP server connected, this prompt lets the agent find your form and key on its own:

Use the Formgong MCP server to add a working contact form to this site.
1. Call list_forms. If there is no form for this site, call create_form with the site name.
2. Call get_form_snippet with that form_id and framework "react" (use "html" for a static page, "next" for the Next.js App Router).
3. Add the returned code as the contact form, styled like the rest of the site. Keep access_key, _lang and the botcheck honeypot exactly as returned.
4. Do not add a backend, API route, database or email code, and never write the fgp_ token into project files.

Check the result

  1. Check that the component starts with "use client" and has no Server Action.
  2. Deploy and send a test message from the live site.
  3. Find the message in the Formgong inbox.
  4. Make sure no RESEND_API_KEY or other secret was added for the form.

The form checker reads the published page and lists concrete problems, such as a missing name attribute or a placeholder key.

Questions

Why not use a Server Action?

A Server Action works, but then you write and maintain the email part yourself, with keys and a sending domain. With Formgong the browser posts the form directly, and storage, email, Telegram and spam filtering are already handled.

Does this work with the Next.js App Router?

Yes. The form is a client component, so it works in the App Router and in the Pages Router. It needs no server code.

Is the access key in the prompt a secret?

No. The access key (fk_…) is public by design. It can only send submissions to one form, which anyone can already do on your site. Secrets, such as a Turnstile secret key or a Formgong API token (fgp_…), must never go into a prompt or frontend code.

How do I put my real key into the prompt?

Copy it from your Formgong dashboard and replace fk_your_access_key. If you are signed in, use the button under the prompt. It reads your forms from your own dashboard in the browser and swaps the key in. Nothing is sent to the AI tool until you paste the prompt.

v0 contact form →

Get a key