netlify-forms
Use this skill whenever a developer wants to add a contact form, signup form, file upload form, or any HTML form to a Netlify site without a backend, or asks why form submissions are missing, going to spam, or returning 404. It covers data-netlify form markup, AJAX/fetch submission, React/Vue/Next.j
- 01GitHub stars
- 51
- 02Installs
- New
- 03Files scanned
- 1
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 28f799b27c131e8f… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Netlify Forms
Use this / not that
<!-- ✅ Reach for this -->
<form name="contact" method="POST" data-netlify="true"> … </form>
// ✅ URL-encoded body built from FormData
fetch(target, {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(new FormData(form)).toString(),
});
// ❌ JSON is NOT supported. Submissions are lost.
fetch(target, { method: "POST", body: JSON.stringify(data) });
netlify(bare attribute) works the same asdata-netlify="true".data-remove-prefixonly applies to legacy forms created before May 5, 2023. Don't add it to new forms.
⚠️ Prerequisite: enable Forms > Enable form detection in the UI (https://app.netlify.com/projects/{site_name}/forms), then redeploy. Without detection, new or changed forms accept no submissions. Enabling has no effect until the next deploy.
How detection works
- At deploy time, Netlify parses the static HTML output and finds
<form>tags withdata-netlify="true"ornetlify. - It strips that attribute (and
netlify-honeypot) and injects<input type="hidden" name="form-name" value="<name>">. - The form
nameis the form's identity in the UI. It must be unique per site. - Fields are identified by their
nameattributes. Multi-selects can usename="role[]". - Forms rendered only by client-side JS or SSR are invisible to the build. They need a static HTML counterpart.
Static HTML form (complete)
<form name="contact" method="POST" data-netlify="true" action="/thank-you">
<input type="hidden" name="subject" value="New lead from %{formName} (%{submissionId})" />
<label>Name <input type="text" name="name" /></label>
<label>Email <input type="email" name="email" /></label>
<label>Role
<select name="role[]" multiple>
<option value="leader">Leader</option>
<option value="follower">Follower</option>
</select>
</label>
<label>Message <textarea name="message"></textarea></label>
<button type="submit">Send</button>
</form>
action: optional custom success page. It must start with/(site-root relative). Without it, visitors see a generic Netlify success page.emailfield: setsReply-toon notification emails. Otherwise replies go to[email protected].subjecthidden input: sets the notification subject (details below).
AJAX for a static page
document.querySelector("form").addEventListener("submit", (event) => {
event.preventDefault();
fetch("/", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(new FormData(event.target)).toString(),
})
.then(() => alert("Thank you for your submission"))
.catch((error) => alert(error));
});
form-name must be in the body. FormData picks up the injected hidden input automatically.
JS-rendered / SSR forms (React, Vue, Gatsby, Next.js, Nuxt, SvelteKit, Astro)
Two parts are required: a detectable static skeleton, plus a component that sends form-name.
1. public/__forms.html — a hidden static copy of every form. Each input name must exactly match what the component submits.
<!DOCTYPE html>
<html>
<body>
<form name="pizzaOrder" data-netlify="true" netlify-honeypot="bot-field" hidden>
<input type="hidden" name="form-name" value="pizzaOrder" />
<input name="bot-field" />
<input name="order" type="text" />
<input name="email" type="email" />
</form>
</body>
</html>
If the form uses Netlify-provided reCAPTCHA, also include <div data-netlify-recaptcha="true"></div> in the skeleton.
2. Component — includes the hidden form-name input (or put form-name in the POST body) and submits via AJAX.
export default function PizzaForm() {
const [status, setStatus] = useState(null);
const handleSubmit = async (event) => {
event.preventDefault();
const body = new URLSearchParams(new FormData(event.target)).toString();
try {
const res = await fetch("/__forms.html", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body,
});
setStatus(res.ok ? "ok" : "error");
} catch {
setStatus("error");
}
};
return (
<form name="pizzaOrder" method="POST" onSubmit={handleSubmit}>
<input type="hidden" name="form-name" value="pizzaOrder" />
<p hidden><input name="bot-field" /></p>
<input name="order" type="text" />
<input name="email" type="email" />
<button type="submit">Order</button>
{status === "ok" && <p>Thanks!</p>}
</form>
);
}
- Next.js Runtime v5 (Next.js 13.5+): form definitions must live in a dedicated static HTML file, and submission must be AJAX, not full-page navigation. See https://docs.netlify.com/build/frameworks/framework-setup-guides/nextjs/overview#v5-breaking-changes
- After AJAX success: handle it in JS, for example
navigate("/thank-you/")in Gatsby, or set state as above.
File uploads
<form name="fileForm" method="POST" enctype="multipart/form-data" data-netlify="true">
<input name="name" type="text" />
<input name="file" type="file" />
<button>Submit</button>
</form>
document.forms.fileForm.addEventListener("submit", (event) => {
event.preventDefault();
fetch("/", { method: "POST", body: new FormData(event.target) }); // NO Content-Type header
});
⚠️ Do not set
Content-Typewhen uploading files. PassFormDatadirectly and let the browser set the multipart boundary.
- One file per
<input type="file">. Use multiple fields for multiple files. - The request is capped at 8 MB total.
- Uploads time out after 30 s.
- For uploads containing PII, add extra security (the docs suggest Very Good Security: https://www.netlify.com/integrations/very-good-security/).
- File links are available in the API, the UI, notification emails, and CSV exports.
Spam protection
Akismet filters every submission automatically. Flagged submissions go to Spam submissions, not the default list.
⚠️ Honeypot and reCAPTCHA failures are rejected outright. They never appear in the spam list, so there is nothing to recover.
Honeypot:
<form name="contact" method="POST" netlify-honeypot="bot-field" data-netlify="true">
<p class="hidden"><label>Don't fill this out: <input name="bot-field" /></label></p>
…
</form>
- The field must be hidden via CSS or JS.
- Any value in the field causes a quiet rejection.
- AJAX bodies must include the honeypot field.
FormDatadoes this.
Netlify-provided reCAPTCHA 2:
- Add
data-netlify-recaptcha="true"on<form>. - Add
<div data-netlify-recaptcha="true"></div>where the widget should render. - Only one per page is allowed. Use custom reCAPTCHA for more.
- On failure, the visitor is redirected back to the same page.
Custom reCAPTCHA 2:
- Add your own Google widget and script.
- Add
data-netlify-recaptcha="true"on<form>. - Set these env vars:
| Var | Value | Scopes |
|---|---|---|
SITE_RECAPTCHA_KEY | site key | Builds + Runtime |
SITE_RECAPTCHA_SECRET | secret key | Runtime |
The body must include a valid g-recaptcha-response (FormData includes it).
Test submissions "missing": they are probably in Akismet spam. Avoid this with a real email (not [email protected]), real sentences in textareas, and spaced-out submissions from the same IP.
Notifications
Configure in Forms > Submission notifications (https://app.netlify.com/projects/{site_name}/forms?tab=notifications).
- Destinations: email, webhook (HTTP POST), or Slack (via https://docs.netlify.com/extend/install-and-use/setup-guides/netlify-app-for-slack).
- Integrations: Zapier and n8n.
- Firing: only on verified submissions, either per form or for all forms.
Email recipients must be active team members or confirmed outside addresses:
- An outside address stays pending confirmation. Nothing is sent until the owner clicks Confirm in the single confirmation email.
- Confirmation is rolling out gradually. If unavailable, saving a non-team address fails validation. Invite the person to the team first.
Subject line:
- Use a hidden
<input type="hidden" name="subject" value="…">. - Variables:
%{formName},%{siteName},%{submissionId}. - The HTML subject overrides the UI subject. To use the UI subject, remove the HTML input.
- Legacy forms created before May 5, 2023 get a
[Netlify]prefix. Drop it either withdata-remove-prefixon thesubjectinput or by setting the subject in the UI.
Submissions & API
API (https://docs.netlify.com/api-and-cli-guides/api-guides/get-started-with-api#forms):
- Supports listing verified and spam submissions, plus deleting submissions or forms.
- Endpoint:
listFormSubmissions(https://open-api.netlify.com/#tag/submission/operation/listFormSubmissions). - The API retains data from renamed or removed fields. The UI shows only fields from the latest deployed form version.
Function on submission: a function can run when a submission is verified. See https://docs.netlify.com/build/functions/trigger-on-events
UI (Forms tab, under Active forms):
- CSV export: Download as CSV exports verified submissions.
- State changes: Mark as spam / Mark as verified.
- Deletion: deleting submissions is permanent.
Submission summary (shown for each item in the UI list):
- Title: the first visible, non-email text
<input>. If none exists, a field namedtitleorsubjectis used. - Body: the first
<textarea>. - If neither exists, the first field with data is shown.
- Field order in your HTML matters.
Sanitization: content is sanitized automatically. <script> is stored as <script>. For PII, export and delete submissions regularly.
Gotchas
⚠️ Deleting a form is irreversible. It deletes all submissions, and future POSTs return
404. Export CSV first. Uploaded files stay reachable by direct URL for 24 h after deletion.
⚠️ Renaming or retyping a field hides old data in the UI. Mark the old field
hiddeninstead of removing it. Old data remains in the API.
- Disabling form detection (Forms > Form detection) is only for sites not using Forms:
- Existing, unchanged forms keep working.
- New or updated forms stop accepting submissions.
- Re-enabling requires a redeploy.
- Custom success page 404s: put a test link with the exact
actionpath on the form page and verify it resolves. - Extra spam prevention: the form detail page shows whether Extra spam prevention (honeypot or reCAPTCHA) is active.
- Debugging guide: https://answers.netlify.com/t/common-issue-how-to-debug-your-form/92
Netlify house rules (forms)
These are org conventions and field-learned guardrails, not docs facts — they are merged into the rendered skill by ctx-gen and are never generated. Extracted from the previous hand-written netlify-forms skill; owned by the skills maintainer.
- In SSR apps (Next.js, Nuxt, SvelteKit, etc.),
fetch("/")is intercepted by the SSR catch-all function and never reaches Netlify's form processing. POST the AJAX submission to the static skeleton file itself (e.g./__forms.html), not to an arbitrary path. - Use only documented surfaces: do not curl
https://api.netlify.com/...with an invented endpoint shape, and do not read tokens out of local CLI config files (~/Library/Preferences/netlify/config.json). - When reading submissions via the API, page through results (
Linkheader); code that reads only the first response silently drops the rest. - For JS-rendered and SSR forms, always create the static skeleton file
public/__forms.html: a hidden copy of each form withdata-netlify="true", a hiddenform-nameinput, and every field the component submits — names matching exactly (Netlify validates field names against the registered form). Without this file, submissions silently fail. - Astro routes rendered on demand (
export const prerender = false, oroutput: "server"routes) are never scanned at build time, so their forms are never registered. Put the form on a prerendered page or rely on the static skeleton file. - A "missing" legitimate submission is usually an Akismet false positive:
check the Spam list (or the API with
?state=spam) and mark it verified. Do not build a custom recovery function or disable spam filtering as a first resort. - For custom success pages, use extensionless
actionpaths (/thank-you, not/thank-you.html) — Netlify servesthank-you.htmlat/thank-youand the.htmlpath returns 404.
Files
1- SKILL.md
41adbb98f013.5 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from netlify/context-and-tools8
Picks the right Netlify site-protection layer and disambiguates the three unrelated "auth" concepts users conflate — app-user login (Netlify Identity), site-load gating (Password Protection / project visibility), and dashboard SAML SSO. Use it when asked to password-protect a site or Deploy Preview,
Run AI agent tasks remotely on Netlify using Claude, Codex, or Gemini. Use when the user wants to run an AI agent on their site, get a second opinion from another model, or delegate development tasks to run remotely against their repo.
Use Netlify AI Gateway to call OpenAI, Anthropic Claude, Google Gemini, Meta, TypeSafe (Jev), or OpenRouter-hosted models (xAI/DeepSeek/Mistral/Qwen) from Netlify Functions or Edge Functions without managing provider accounts or API keys. Reach for this when adding an AI feature to a Netlify app — a
Store and retrieve unstructured objects, files, and cache-like state on Netlify with the @netlify/blobs module. Use when persisting user file uploads (images/documents), caching computed output from functions or Background Functions, serving downloadable assets, storing JSON blobs keyed by ID, or se
Cache dynamic and static responses on Netlify's CDN from Functions, Edge Functions, Netlify Server, and proxies. Use when you add caching or cache-control headers to a function or server response, tune cache TTL or stale-while-revalidate, set up the durable cache, vary a cache key by query/header/co
Configure Netlify builds and routing via netlify.toml, _redirects, and _headers. Use when setting a build command or publish directory, validating netlify.toml against its JSON schema, adding redirects/rewrites/proxies or an SPA fallback rewrite, or setting custom response headers or basic auth. Als
Use this skill whenever a Netlify project needs a Postgres database. It covers Netlify Database setup, queries from Functions or Edge Functions, schema changes through migrations in netlify/database/migrations, Drizzle ORM wiring, local dev databases and tests, deploy-preview database branches, and
Create, configure, and manage Netlify deploys from code — reach for this when setting up Git continuous deployment, running netlify deploy or netlify deploy --prod from the CLI, writing netlify.toml deploy contexts, adding a Deploy to Netlify button, wiring build hooks, configuring Deploy Previews o
Related frontend skillsscan passed
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
Master React Native styling, navigation, and Reanimated animations for cross-platform mobile development. Use when building React Native apps, implementing navigation patterns, or creating performant animations.
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
Reviews a screen, flow or whole interface across accessibility, layout, writing, typography, color, UI polish and motion, and returns one ranked report.
Use when asked to brainstorm, evaluate whether an idea is worth building, run office hours, or think through a new product idea or design direction before any code is written.
Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex/grid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, p