Loading...
Loading...
Compare original and translation side by side
data-netlify="true"name<form name="contact" method="POST" data-netlify="true">
<label>Name: <input type="text" name="name" /></label>
<label>Email: <input type="email" name="email" /></label>
<label>Message: <textarea name="message"></textarea></label>
<button type="submit">Send</button>
</form>form-nameaction="/thank-you".htmlthank-you.html/thank-you.htmldata-netlify="true"name<form name="contact" method="POST" data-netlify="true">
<label>Name: <input type="text" name="name" /></label>
<label>Email: <input type="email" name="email" /></label>
<label>Message: <textarea name="message"></textarea></label>
<button type="submit">Send</button>
</form>form-nameaction="/thank-you".html/thank-youthank-you.html.htmlpublic/public/__forms.html<!DOCTYPE html>
<html>
<body>
<form name="contact" data-netlify="true" netlify-honeypot="bot-field" hidden>
<input type="hidden" name="form-name" value="contact" />
<input type="text" name="name" />
<input type="email" name="email" />
<textarea name="message"></textarea>
<input name="bot-field" />
</form>
</body>
</html>nameform-nameform-name<form name="contact" method="POST" data-netlify="true">
<input type="hidden" name="form-name" value="contact" />
{/* ... fields ... */}
</form>public/public/__forms.html<!DOCTYPE html>
<html>
<body>
<form name="contact" data-netlify="true" netlify-honeypot="bot-field" hidden>
<input type="hidden" name="form-name" value="contact" />
<input type="text" name="name" />
<input type="email" name="email" />
<textarea name="message"></textarea>
<input name="bot-field" />
</form>
</body>
</html>nameform-nameform-name<form name="contact" method="POST" data-netlify="true">
<input type="hidden" name="form-name" value="contact" />
{/* ... fields ... */}
</form>const form = document.querySelector("form");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(form);
await fetch("/", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(formData).toString(),
});
});SSR frameworks (TanStack Start, Next.js, SvelteKit, Remix, Nuxt): TheURL must target the static skeleton file path (e.g.fetch), not"/__forms.html". In SSR apps,"/"is intercepted by the SSR catch-all function and never reaches Netlify's form processing middleware. See the React example and troubleshooting section below.fetch("/")
const form = document.querySelector("form");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const formData = new FormData(form);
await fetch("/", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(formData).toString(),
});
});SSR框架(TanStack Start、Next.js、SvelteKit、Remix、Nuxt):的请求地址必须指向静态骨架文件的路径(比如fetch),不能是"/__forms.html"。在SSR应用中,"/"会被SSR的全局捕获函数拦截,永远无法到达Netlify的表单处理中间件。参考下方的React示例和故障排查部分。fetch("/")
function ContactForm() {
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
// For SSR apps, use the skeleton file path instead of "/" (e.g. "/__forms.html")
const response = await fetch("/__forms.html", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(formData as any).toString(),
});
if (response.ok) {
// Show success feedback
}
};
return (
<form name="contact" method="POST" data-netlify="true" onSubmit={handleSubmit}>
<input type="hidden" name="form-name" value="contact" />
<input type="text" name="name" placeholder="Name" />
<input type="email" name="email" placeholder="Email" />
<textarea name="message" placeholder="Message" />
<button type="submit">Send</button>
</form>
);
}SSR troubleshooting: If form submissions appear to succeed (200 response) but nothing shows in the Netlify Forms UI, the POST is likely being intercepted by the SSR function. Ensuretargets the skeleton file path (e.g.fetch), not"/__forms.html". The skeleton file path routes through the CDN origin where Netlify's form handler runs."/"
function ContactForm() {
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
// For SSR apps, use the skeleton file path instead of "/" (e.g. "/__forms.html")
const response = await fetch("/__forms.html", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams(formData as any).toString(),
});
if (response.ok) {
// Show success feedback
}
};
return (
<form name="contact" method="POST" data-netlify="true" onSubmit={handleSubmit}>
<input type="hidden" name="form-name" value="contact" />
<input type="text" name="name" placeholder="Name" />
<input type="email" name="email" placeholder="Email" />
<textarea name="message" placeholder="Message" />
<button type="submit">Send</button>
</form>
);
}SSR故障排查: 如果表单提交看起来成功了(返回200响应),但Netlify Forms UI中没有显示任何数据,那么POST请求很可能被SSR函数拦截了。请确保请求的目标是骨架文件路径(比如fetch),而不是"/__forms.html"。骨架文件路径会通过CDN源站路由,Netlify的表单处理程序会在那里运行。"/"
<form name="contact" method="POST" netlify-honeypot="bot-field" data-netlify="true">
<p style="display:none">
<label>Don't fill this out: <input name="bot-field" /></label>
</p>
<!-- visible fields -->
</form>data-netlify-recaptcha="true"<div data-netlify-recaptcha="true"></div><form name="contact" method="POST" netlify-honeypot="bot-field" data-netlify="true">
<p style="display:none">
<label>Don't fill this out: <input name="bot-field" /></label>
</p>
<!-- visible fields -->
</form>data-netlify-recaptcha="true"<div data-netlify-recaptcha="true"></div><form name="upload" enctype="multipart/form-data" data-netlify="true">
<input type="text" name="name" />
<input type="file" name="attachment" />
<button type="submit">Upload</button>
</form>FormDataContent-Typeawait fetch("/", { method: "POST", body: new FormData(form) });<form name="upload" enctype="multipart/form-data" data-netlify="true">
<input type="text" name="name" />
<input type="file" name="attachment" />
<button type="submit">Upload</button>
</form>FormDataContent-Typeawait fetch("/", { method: "POST", body: new FormData(form) });<input type="hidden" name="subject" value="Contact form" /><input type="hidden" name="subject" value="Contact form" />GET /api/v1/forms/{form_id}/submissions
Authorization: Bearer <PERSONAL_ACCESS_TOKEN>| Action | Method | Path |
|---|---|---|
| List forms | GET | |
| Get submissions | GET | |
| Get spam | GET | |
| Delete submission | DELETE | |
GET /api/v1/forms/{form_id}/submissions
Authorization: Bearer <PERSONAL_ACCESS_TOKEN>| 操作 | 请求方法 | 路径 |
|---|---|---|
| 列出所有表单 | GET | |
| 获取提交数据 | GET | |
| 获取垃圾提交数据 | GET | |
| 删除提交数据 | DELETE | |