跳到主内容
智客 ZICQ

技能库 智客分类:运维与云 netlify-forms

Netlify Forms

在Netlify-托管站点进行无服务器格式处理——在部署时检测HTML格式,存储提交,过滤垃圾邮件,并发送通知. 在Netlify网站添加联系表,线索抓取表,文件上载表,或通讯签名时使用;将 AJAX 格式提交; 设置自定义谢页; 在表格中添加蜂蜜壶或 reCAPTCHA ; 在 Next.js, Nuxt, SvelteKit, Astro, 或 Gatsby 中获取表格工作; 通过Netlify API读取表格提交; 调试缺失的提交和默默未注册的表格 .

2437 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

Netlify托管站点上的无服务器窗体处理——在部署时检测 HTML 窗体,存储提交文件,过滤垃圾邮件并发送通知

何时用

在Netlify网站添加联系表、铅抓取表、文件上载表或通讯签名; 连接 AJAX 表格提交; 设置自定义的谢页; 在表格中添加蜂蜜壶或 reCAPTCHA; 获取在 Next.js、 Nuxt、 SvelteKit、 Astro 或 Gatsby 工作的表格; 读取

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Netlify Forms、Static HTML form、JS-rendered / SSR / framework forms (Next.js, Nuxt, SvelteKit, Astro, Gatsby)、AJAX submission、File uploads、Custom success page。

文件分析

文件分析:除 SKILL.md 外,正文还引用了 references/,属于带资源的技能包,代理会按需再读这些文件。

官方 description(原文)

Serverless form handling on Netlify-hosted sites — detects HTML forms at deploy time, stores submissions, filters spam, and sends notifications. Use when adding a contact form, lead-capture form, file-upload form, or newsletter signup to a Netlify site; wiring AJAX form submission; setting up a custom thank-you page; adding a honeypot or reCAPTCHA to a form; getting forms working in Next.js, Nuxt, SvelteKit, Astro, or Gatsby; reading form submissions via the Netlify API; or debugging missing submissions and forms that silently fail to register.

Netlify FormsStatic HTML formJS-rendered / SSR / framework forms (Next.js, Nuxt, SvelteKit, Astro, Gatsby)AJAX submissionFile uploadsCustom success pageSpam preventionEmail notifications & subject lineReading submissions via the APISubmission summary (field order matters)Debugging missing submissionsConstraints

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
netlify-forms
description
Serverless form handling on Netlify-hosted sites — detects HTML forms at deploy time, stores submissions, filters spam, and sends notifications. Use when adding a contact form, lead-capture form, file-upload form, or newsletter signup to a Netlify site; wiring AJAX form submission; setting up a custom thank-you page; adding a honeypot or reCAPTCHA to a form; getting forms working in Next.js, Nuxt, SvelteKit, Astro, or Gatsby; reading form submissions via the Netlify API; or debugging missing submissions and forms that silently fail to register.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「netlify-forms」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-fb2737eca1164588-%E4%BA%92%E6%8D%A2%E8%A1%A8%E6%A0%BC.html
请存为 .cursor/skills/netlify-forms/SKILL.md 或 .claude/skills/netlify-forms/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/netlify/context-and-tools 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/netlify/context-and-tools' --list

npx skills add 'https://github.com/netlify/context-and-tools' --skill 'netlify-forms'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: netlify-forms description: Serverless form handling on Netlify-hosted sites — detects HTML forms at deploy time, stores submissions, filters spam, and sends notifications. Use when adding a contact form, lead-capture form, file-upload form, or newsletter signup to a Netlify site; wiring AJAX form submission; setting up a custom thank-you page; adding a honeypot or reCAPTCHA to a form; getting forms working in Next.js, Nuxt, SvelteKit, Astro, or Gatsby; reading form submissions via the Netlify API; or debugging missing submissions and forms that silently fail to register. --- # Netlify Forms Mark a form for detection with `data-netlify="true"` (or the bare `netlify` attribute — equivalent) on the `` tag. Forms are detected by **parsing the final built HTML at deploy time** — there is no runtime API call or backend code. Client-side/JS-rendered/SSR forms are NOT in the built HTML and are never detected on their own; they require a static skeleton file (see below). Prerequisite: form detection must be enabled once in the Netlify UI (Forms > **Enable form detection**). Takes effect on the next deploy. ## Static HTML form ```html

Your Name:

Your Email:

Message:

Send

``` - `name` sets the form name in the UI and **must be unique per site**. - At deploy, Netlify strips the `data-netlify`/`netlify` attribute and injects ``. - Add an `` so the notification email's `Reply-to` is set to the submitter. ## JS-rendered / SSR / framework forms (Next.js, Nuxt, SvelteKit, Astro, Gatsby) Two required pieces: **1. Static skeleton file `public/__forms.html`** — a hidden copy of each form with `data-netlify="true"`, a hidden `form-name` input, and every field the component submits, with names matching **exactly** (Netlify validates field names against the registered form). Without this file, submissions silently fail. ```html ``` **2. The rendered form** carries a matching hidden `form-name` input: ```jsx ``` **⚠️ SSR POST target:** In SSR apps, `fetch("/")` is intercepted by the SSR catch-all function and never reaches form processing. POST to the static skeleton file itself — `/__forms.html` — not `/` or an arbitrary path. **⚠️ Astro on-demand routes:** Routes with `export const prerender = false` or `output: "server"` 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. **Next.js Runtime v5 (Next.js 13.5+):** extract form definitions to the static skeleton file and submit via AJAX rather than full-page navigation. See https://docs.netlify.com/build/frameworks/framework-setup-guides/nextjs/overview#v5-breaking-changes ## AJAX submission ```js const handleSubmit = event => { event.preventDefault(); const formData = new FormData(event.target); fetch("/__forms.html", { // static sites may POST to "/"; SSR must target the skeleton file method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: new URLSearchParams(formData).toString() }) .then(() => alert("Thank you for your submission")) // or navigate("/thank-you") .catch(error => alert(error)); }; document.querySelector("form").addEventListener("submit", handleSubmit); ``` - **Body MUST be URL-encoded. JSON is NOT supported.** - If the rendered form has no hidden `form-name` input, you MUST include a `form-name` field in the POST body. - The honeypot field name and `g-recaptcha-response` (if used) must be in the body — automatic with `FormData()`. ## File uploads Add `type="file"`; optionally `enctype="multipart/form-data"` on the ``. For AJAX file uploads, **do NOT set a `Content-Type` header** — let the browser set it (with the multipart boundary). ```js document.forms.fileForm.addEventListener("submit", event => { event.preventDefault(); fetch("/", { body: new FormData(event.target), method: "POST" }) // no headers .then(() => { /* success */ }); }); ``` Limits: one file per field (use multiple fields for multiple files) · 8 MB max request size · 30 s upload timeout · after form deletion, uploaded files stay at their direct URL for 24 h. PII uploads need extra security (Very Good Security integration). ## Custom success page Add an `action` path relative to site root, starting with `/`. **Use extensionless paths** — Netlify serves `thank-you.html` at `/thank-you`; the `.html` path returns 404. ```html ``` Custom success *alert* is only possible via AJAX (substitute the redirect with your own logic). ## Spam prevention All submissions are filtered by Akismet. Passed → **Verified submissions**; flagged → **Spam submissions**. Honeypot/reCAPTCHA failures are rejected and appear in neither list. **Honeypot:** add `netlify-honeypot="bot-field"` to the `` and include a CSS-hidden field of that name. Any value entered → submission quietly rejected. ```html

Don’t fill this out:

``` **Netlify reCAPTCHA 2:** add `data-netlify-recaptcha="true"` to the `` AND an empty `
` where it renders. Only ONE Netlify-provided challenge per page — for multiple, use custom reCAPTCHA. For JS-rendered forms, also add the `div` to the static skeleton file. **Custom reCAPTCHA 2:** your own reCAPTCHA snippet + `data-netlify-recaptcha="true"` on the ``, plus env vars: - `SITE_RECAPTCHA_KEY` — site key (scopes: Builds + Runtime) - `SITE_RECAPTCHA_SECRET` — secret (scope: Runtime) ## Email notifications & subject line Default sender: `[email protected]`. Set subject via a hidden `subject` input **or** the Netlify UI (Configuration > Notifications) — **not both; the HTML value always overrides the UI.** ```html ``` Variables: `%{formName}`, `%{siteName}`, `%{submissionId}`. Forms created before **May 5, 2023** carry a `[Netlify]` subject prefix — remove it by adding the `data-remove-prefix` attribute to the `subject` input. Set up notifications (email/webhook/Slack) in the UI: Configuration > Notifications > Form submission notifications > **Add notification**. ## Reading submissions via the API Use only documented surfaces. Do NOT invent `api.netlify.com` endpoints or read tokens from local CLI config files. Reference: https://open-api.netlify.com/#tag/submission/operation/listFormSubmissions - **Page through results using the `Link` header** — code that reads only the first response silently drops the rest. - `listFormSubmissions` returns data from old/removed fields no longer shown in the UI. - Query spam with `?state=spam`. ## Submission summary (field order matters) The UI summary is derived from field **type**, not name: - **Title**: first non-hidden text `` that isn't email-like (`type="email"`, or name matching `email`/`mail`/`from`/`twitter`/`sender`); falls back to a field named `title` or `subject`. - **Body**: first ``. Field order in the HTML affects what appears in the summary. ## Debugging missing submissions - **First suspect: Akismet false positive.** A missing legitimate submission is usually spam-flagged — check the **Spam** list (or API `?state=spam`) and mark it verified. Do NOT build a custom recovery function or disable spam filtering as a first resort. - Test submissions get flagged as spam: use a real email (not `[email protected]`), write full sentences, don't hammer from one IP. - No submissions at all: confirm form detection is enabled and redeploy. - SSR/JS forms silently failing: verify the static skeleton file exists with exactly-matching field names and that AJAX targets the skeleton file, not `/`. - Missing old-field data: the UI shows only fields from the last deployed form version. Mark old fields `hidden` instead of removing them to keep them visible; old data remains available via `listFormSubmissions`. ## Constraints - Deleting a form is permanent: future submissions return `404`, past submissions become unavailable. Export CSV first. - Submitted code is sanitized (`<script>` → escaped entities). - For PII, export and delete data regularly. - Data is stored in Netlify's database, not accessible except via UI/API/CSV. <!-- system: agent-context/forms/system.md — human-owned, merged by ctx-gen; edit system.md, not this section --> # 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. 1. 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. 2. 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`). 3. When reading submissions via the API, page through results (`Link` header); code that reads only the first response silently drops the rest. 4. For JS-rendered and SSR forms, always create the static skeleton file `public/__forms.html`: a hidden copy of each form with `data-netlify="true"`, a hidden `form-name` input, and every field the component submits — names matching exactly (Netlify validates field names against the registered form). Without this file, submissions silently fail. 5. Astro routes rendered on demand (`export const prerender = false`, or `output: "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. 6. 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. 7. For custom success pages, use extensionless `action` paths (`/thank-you`, not `/thank-you.html`) — Netlify serves `thank-you.html` at `/thank-you` and the `.html` path returns 404.

相关技能

运维与云

Docker Essentials

用于容器管理,图像操作,调试的基本道克命令和工作流程.

运维与云

Find Skills

从开放的代理技能生态系统中发现并安装技能. 使用时:(1)用户问"我如何做X",X可能拥有现有技能,(2)用户说"为X找到技能"或"是否为X有技能",(3)用户问"你能否做X",X是专门能力,(4)用户想扩展代理能力,(5)用户想搜索工具,模板,或工作流程,(6)用户提到他们希望…

运维与云

Microsoft Foundry

构建,部署,评价,优化,微调,管理微软创始代理,模型,资源最终结束. 用法:铸造、azd ai代理、azd 提供/部署、托管代理脚手架/开发/运行/部署/拖放、即时代理创建、创建代理、更新代理、添加代理工具、援引代理、代理.yaml、评估代理、批量活化、连续活化、持续监测、代理C…

运维与云

Azure Deploy

执行已有.azure/部署计划.md和基础设施文件的ALREADY-PREPARED应用程序的Azure部署。 当用户向 CREATE 请求新应用程序时, 请不要使用此技能 。 这种技能运行了 azd上行, azd 部署, trarraform 应用, 和 az 部署命令带有内置…