[{"data":1,"prerenderedAt":3297},["ShallowReactive",2],{"page:\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fadding-a-contact-form-with-cloudflare-workers":3,"all-docs-nav":2754},{"id":4,"title":5,"body":6,"breadcrumb":2729,"dateModified":2738,"datePublished":2738,"description":2739,"extension":2740,"faq":2741,"meta":2748,"navigation":651,"path":2749,"seo":2750,"slug":12,"stem":2751,"type":2752,"__hash__":2753},"content\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fadding-a-contact-form-with-cloudflare-workers\u002Findex.md","Adding a Contact Form with Cloudflare Workers",{"type":7,"value":8,"toc":2711},"minimark",[9,13,22,36,41,54,58,531,541,545,1658,1661,1831,1835,1938,2009,2015,2019,2030,2202,2310,2317,2321,2324,2390,2398,2402,2405,2504,2573,2577,2626,2630,2633,2637,2642,2645,2649,2652,2656,2659,2663,2666,2670,2707],[10,11,5],"h1",{"id":12},"adding-a-contact-form-with-cloudflare-workers",[14,15,16,17,21],"p",{},"A contact form is the smallest piece of server code a static site needs, and a good first function to own. On Cloudflare Pages or Workers with static assets, it is one file under ",[18,19,20],"code",{},"functions\u002F",", deployed with the site in the same commit: it validates the submission, checks a Turnstile token to stop bots, rate-limits by IP, writes the message to a D1 database, emails the team and redirects the reader to a thank-you page. The page stays static; the form works without JavaScript; nothing leaves your Cloudflare account except the notification email.",[14,23,24,25,30,31,35],{},"This guide builds that handler for a 700-page Astro documentation site and reports four weeks of results. The comparison with other approaches is in ",[26,27,29],"a",{"href":28},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fhandling-form-submissions-on-a-static-site\u002F","Handling Form Submissions on a Static Site","; the wider context is ",[26,32,34],{"href":33},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002F","Serverless Functions for Static Sites",".",[37,38,40],"h2",{"id":39},"prerequisites","Prerequisites",[42,43,44,48,51],"ul",{},[45,46,47],"li",{},"A site on Cloudflare Pages (or Workers with static assets) deployed with Wrangler.",[45,49,50],{},"A Turnstile widget created in the Cloudflare dashboard (site key and secret key).",[45,52,53],{},"A D1 database, and an email provider's API key or Email Routing set up for the destination address.",[37,55,57],{"id":56},"step-1-the-form-and-thank-you-page","Step 1: The Form and Thank-You Page",[59,60,65],"pre",{"className":61,"code":62,"language":63,"meta":64,"style":64},"language-html shiki shiki-themes github-light github-dark","\u003C!-- src\u002Fpages\u002Fcontact.astro (excerpt) -->\n\u003Cform method=\"post\" action=\"\u002Fapi\u002Fcontact\" id=\"contact\">\n  \u003Clabel for=\"name\">Name\u003C\u002Flabel>\n  \u003Cinput id=\"name\" name=\"name\" required maxlength=\"100\" autocomplete=\"name\">\n  \u003Clabel for=\"email\">Email\u003C\u002Flabel>\n  \u003Cinput id=\"email\" name=\"email\" type=\"email\" required maxlength=\"200\" autocomplete=\"email\">\n  \u003Clabel for=\"message\">Message\u003C\u002Flabel>\n  \u003Ctextarea id=\"message\" name=\"message\" required maxlength=\"5000\" rows=\"6\">\u003C\u002Ftextarea>\n  \u003Cdiv hidden>\u003Clabel>Website \u003Cinput name=\"website\" tabindex=\"-1\" autocomplete=\"off\">\u003C\u002Flabel>\u003C\u002Fdiv>\n  \u003Cinput type=\"hidden\" name=\"ts\" id=\"ts\">\n  \u003Cdiv class=\"cf-turnstile\" data-sitekey=\"0x4AAAAAAA…\" data-appearance=\"interaction-only\">\u003C\u002Fdiv>\n  \u003Cbutton type=\"submit\">Send\u003C\u002Fbutton>\n\u003C\u002Fform>\n\u003Cscript src=\"https:\u002F\u002Fchallenges.cloudflare.com\u002Fturnstile\u002Fv0\u002Fapi.js\" async defer>\u003C\u002Fscript>\n\u003Cscript is:inline>document.getElementById('ts').value = Date.now();\u003C\u002Fscript>\n","html","",[18,66,67,76,117,141,182,203,246,267,311,364,393,430,452,462,490],{"__ignoreMap":64},[68,69,72],"span",{"class":70,"line":71},"line",1,[68,73,75],{"class":74},"sJ8bj","\u003C!-- src\u002Fpages\u002Fcontact.astro (excerpt) -->\n",[68,77,79,83,87,91,94,98,101,103,106,109,111,114],{"class":70,"line":78},2,[68,80,82],{"class":81},"sVt8B","\u003C",[68,84,86],{"class":85},"s9eBZ","form",[68,88,90],{"class":89},"sScJk"," method",[68,92,93],{"class":81},"=",[68,95,97],{"class":96},"sZZnC","\"post\"",[68,99,100],{"class":89}," action",[68,102,93],{"class":81},[68,104,105],{"class":96},"\"\u002Fapi\u002Fcontact\"",[68,107,108],{"class":89}," id",[68,110,93],{"class":81},[68,112,113],{"class":96},"\"contact\"",[68,115,116],{"class":81},">\n",[68,118,120,123,126,129,131,134,137,139],{"class":70,"line":119},3,[68,121,122],{"class":81},"  \u003C",[68,124,125],{"class":85},"label",[68,127,128],{"class":89}," for",[68,130,93],{"class":81},[68,132,133],{"class":96},"\"name\"",[68,135,136],{"class":81},">Name\u003C\u002F",[68,138,125],{"class":85},[68,140,116],{"class":81},[68,142,144,146,149,151,153,155,158,160,162,165,168,170,173,176,178,180],{"class":70,"line":143},4,[68,145,122],{"class":81},[68,147,148],{"class":85},"input",[68,150,108],{"class":89},[68,152,93],{"class":81},[68,154,133],{"class":96},[68,156,157],{"class":89}," name",[68,159,93],{"class":81},[68,161,133],{"class":96},[68,163,164],{"class":89}," required",[68,166,167],{"class":89}," maxlength",[68,169,93],{"class":81},[68,171,172],{"class":96},"\"100\"",[68,174,175],{"class":89}," autocomplete",[68,177,93],{"class":81},[68,179,133],{"class":96},[68,181,116],{"class":81},[68,183,185,187,189,191,193,196,199,201],{"class":70,"line":184},5,[68,186,122],{"class":81},[68,188,125],{"class":85},[68,190,128],{"class":89},[68,192,93],{"class":81},[68,194,195],{"class":96},"\"email\"",[68,197,198],{"class":81},">Email\u003C\u002F",[68,200,125],{"class":85},[68,202,116],{"class":81},[68,204,206,208,210,212,214,216,218,220,222,225,227,229,231,233,235,238,240,242,244],{"class":70,"line":205},6,[68,207,122],{"class":81},[68,209,148],{"class":85},[68,211,108],{"class":89},[68,213,93],{"class":81},[68,215,195],{"class":96},[68,217,157],{"class":89},[68,219,93],{"class":81},[68,221,195],{"class":96},[68,223,224],{"class":89}," type",[68,226,93],{"class":81},[68,228,195],{"class":96},[68,230,164],{"class":89},[68,232,167],{"class":89},[68,234,93],{"class":81},[68,236,237],{"class":96},"\"200\"",[68,239,175],{"class":89},[68,241,93],{"class":81},[68,243,195],{"class":96},[68,245,116],{"class":81},[68,247,249,251,253,255,257,260,263,265],{"class":70,"line":248},7,[68,250,122],{"class":81},[68,252,125],{"class":85},[68,254,128],{"class":89},[68,256,93],{"class":81},[68,258,259],{"class":96},"\"message\"",[68,261,262],{"class":81},">Message\u003C\u002F",[68,264,125],{"class":85},[68,266,116],{"class":81},[68,268,270,272,275,277,279,281,283,285,287,289,291,293,296,299,301,304,307,309],{"class":70,"line":269},8,[68,271,122],{"class":81},[68,273,274],{"class":85},"textarea",[68,276,108],{"class":89},[68,278,93],{"class":81},[68,280,259],{"class":96},[68,282,157],{"class":89},[68,284,93],{"class":81},[68,286,259],{"class":96},[68,288,164],{"class":89},[68,290,167],{"class":89},[68,292,93],{"class":81},[68,294,295],{"class":96},"\"5000\"",[68,297,298],{"class":89}," rows",[68,300,93],{"class":81},[68,302,303],{"class":96},"\"6\"",[68,305,306],{"class":81},">\u003C\u002F",[68,308,274],{"class":85},[68,310,116],{"class":81},[68,312,314,316,319,322,325,327,330,332,334,336,339,342,344,347,349,351,354,356,358,360,362],{"class":70,"line":313},9,[68,315,122],{"class":81},[68,317,318],{"class":85},"div",[68,320,321],{"class":89}," hidden",[68,323,324],{"class":81},">\u003C",[68,326,125],{"class":85},[68,328,329],{"class":81},">Website \u003C",[68,331,148],{"class":85},[68,333,157],{"class":89},[68,335,93],{"class":81},[68,337,338],{"class":96},"\"website\"",[68,340,341],{"class":89}," tabindex",[68,343,93],{"class":81},[68,345,346],{"class":96},"\"-1\"",[68,348,175],{"class":89},[68,350,93],{"class":81},[68,352,353],{"class":96},"\"off\"",[68,355,306],{"class":81},[68,357,125],{"class":85},[68,359,306],{"class":81},[68,361,318],{"class":85},[68,363,116],{"class":81},[68,365,367,369,371,373,375,378,380,382,385,387,389,391],{"class":70,"line":366},10,[68,368,122],{"class":81},[68,370,148],{"class":85},[68,372,224],{"class":89},[68,374,93],{"class":81},[68,376,377],{"class":96},"\"hidden\"",[68,379,157],{"class":89},[68,381,93],{"class":81},[68,383,384],{"class":96},"\"ts\"",[68,386,108],{"class":89},[68,388,93],{"class":81},[68,390,384],{"class":96},[68,392,116],{"class":81},[68,394,396,398,400,403,405,408,411,413,416,419,421,424,426,428],{"class":70,"line":395},11,[68,397,122],{"class":81},[68,399,318],{"class":85},[68,401,402],{"class":89}," class",[68,404,93],{"class":81},[68,406,407],{"class":96},"\"cf-turnstile\"",[68,409,410],{"class":89}," data-sitekey",[68,412,93],{"class":81},[68,414,415],{"class":96},"\"0x4AAAAAAA…\"",[68,417,418],{"class":89}," data-appearance",[68,420,93],{"class":81},[68,422,423],{"class":96},"\"interaction-only\"",[68,425,306],{"class":81},[68,427,318],{"class":85},[68,429,116],{"class":81},[68,431,433,435,438,440,442,445,448,450],{"class":70,"line":432},12,[68,434,122],{"class":81},[68,436,437],{"class":85},"button",[68,439,224],{"class":89},[68,441,93],{"class":81},[68,443,444],{"class":96},"\"submit\"",[68,446,447],{"class":81},">Send\u003C\u002F",[68,449,437],{"class":85},[68,451,116],{"class":81},[68,453,455,458,460],{"class":70,"line":454},13,[68,456,457],{"class":81},"\u003C\u002F",[68,459,86],{"class":85},[68,461,116],{"class":81},[68,463,465,467,470,473,475,478,481,484,486,488],{"class":70,"line":464},14,[68,466,82],{"class":81},[68,468,469],{"class":85},"script",[68,471,472],{"class":89}," src",[68,474,93],{"class":81},[68,476,477],{"class":96},"\"https:\u002F\u002Fchallenges.cloudflare.com\u002Fturnstile\u002Fv0\u002Fapi.js\"",[68,479,480],{"class":89}," async",[68,482,483],{"class":89}," defer",[68,485,306],{"class":81},[68,487,469],{"class":85},[68,489,116],{"class":81},[68,491,493,495,497,500,503,506,509,512,515,518,521,524,527,529],{"class":70,"line":492},15,[68,494,82],{"class":81},[68,496,469],{"class":85},[68,498,499],{"class":89}," is:inline",[68,501,502],{"class":81},">document.",[68,504,505],{"class":89},"getElementById",[68,507,508],{"class":81},"(",[68,510,511],{"class":96},"'ts'",[68,513,514],{"class":81},").value ",[68,516,93],{"class":517},"szBVR",[68,519,520],{"class":81}," Date.",[68,522,523],{"class":89},"now",[68,525,526],{"class":81},"();\u003C\u002F",[68,528,469],{"class":85},[68,530,116],{"class":81},[14,532,533,534,537,538,35],{},"The Turnstile script loads asynchronously and only on the contact page, so other pages carry no cost. ",[18,535,536],{},"data-appearance=\"interaction-only\""," keeps the widget invisible unless Cloudflare decides a visitor needs an interactive check. The thank-you page is a normal static page at ",[18,539,540],{},"\u002Fcontact\u002Fthanks\u002F",[37,542,544],{"id":543},"step-2-the-function","Step 2: The Function",[59,546,550],{"className":547,"code":548,"language":549,"meta":64,"style":64},"language-js shiki shiki-themes github-light github-dark","\u002F\u002F functions\u002Fapi\u002Fcontact.js\nconst LIMIT = { name: 100, email: 200, message: 5000 };\nconst EMAIL = \u002F^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$\u002F;\n\nexport async function onRequestPost({ request, env }) {\n  const f = await request.formData();\n  const get = (k) => (f.get(k) ?? '').toString().trim();\n  const ip = request.headers.get('cf-connecting-ip') ?? '';\n\n  \u002F\u002F 1. cheap bot checks\n  if (get('website')) return redirect('\u002Fcontact\u002Fthanks\u002F');           \u002F\u002F honeypot: pretend success\n  if (Date.now() - Number(get('ts')) \u003C 3000) return redirect('\u002Fcontact\u002Fthanks\u002F');\n\n  \u002F\u002F 2. validation\n  const data = { name: get('name'), email: get('email'), message: get('message') };\n  for (const [k, max] of Object.entries(LIMIT)) if (!data[k] || data[k].length > max) return fail(`Please check the ${k} field.`);\n  if (!EMAIL.test(data.email)) return fail('Please enter a valid email address.');\n\n  \u002F\u002F 3. rate limit: 5 per IP per hour\n  const { success } = await env.CONTACT_LIMITER.limit({ key: ip });\n  if (!success) return fail('Too many messages from this address. Please try again later.', 429);\n\n  \u002F\u002F 4. Turnstile\n  const ts = await fetch('https:\u002F\u002Fchallenges.cloudflare.com\u002Fturnstile\u002Fv0\u002Fsiteverify', {\n    method: 'POST',\n    body: new URLSearchParams({ secret: env.TURNSTILE_SECRET, response: get('cf-turnstile-response'), remoteip: ip }),\n  }).then((r) => r.json());\n  if (!ts.success) return fail('Verification failed. Please try again.');\n\n  \u002F\u002F 5. store first, then notify\n  const id = crypto.randomUUID();\n  await env.DB.prepare('INSERT INTO messages (id, name, email, message, created) VALUES (?, ?, ?, ?, ?)')\n    .bind(id, data.name, data.email, data.message, new Date().toISOString()).run();\n  if (env.ENVIRONMENT === 'production') {\n    await fetch('https:\u002F\u002Fapi.email-provider.example\u002Fv1\u002Fsend', {\n      method: 'POST',\n      headers: { authorization: `Bearer ${env.EMAIL_KEY}`, 'content-type': 'application\u002Fjson' },\n      body: JSON.stringify({ to: 'docs-team@example.com', reply_to: data.email,\n        subject: `Contact: ${data.name}`, text: `${data.message}\\n\\n— ${data.name} \u003C${data.email}>\\nID ${id}` }),\n      signal: AbortSignal.timeout(5000),\n    }).catch(() => {});                                                 \u002F\u002F stored already; email is best effort\n  }\n  return redirect('\u002Fcontact\u002Fthanks\u002F');\n}\n\nconst redirect = (to) => new Response(null, { status: 303, headers: { location: to } });\nconst fail = (msg, status = 400) => new Response(\n  `\u003C!doctype html>\u003Ctitle>Message not sent\u003C\u002Ftitle>\u003Cp>${msg}\u003C\u002Fp>\u003Cp>\u003Ca href=\"\u002Fcontact\u002F\">Back to the form\u003C\u002Fa>\u003C\u002Fp>`,\n  { status, headers: { 'content-type': 'text\u002Fhtml; charset=utf-8' } });\n","js",[18,551,552,557,590,647,653,682,704,754,781,785,790,824,870,874,879,920,1002,1033,1038,1044,1076,1104,1109,1115,1138,1150,1181,1209,1232,1237,1243,1260,1284,1314,1334,1349,1359,1392,1415,1489,1505,1525,1531,1545,1551,1556,1594,1629,1642],{"__ignoreMap":64},[68,553,554],{"class":70,"line":71},[68,555,556],{"class":74},"\u002F\u002F functions\u002Fapi\u002Fcontact.js\n",[68,558,559,562,566,569,572,575,578,581,584,587],{"class":70,"line":78},[68,560,561],{"class":517},"const",[68,563,565],{"class":564},"sj4cs"," LIMIT",[68,567,568],{"class":517}," =",[68,570,571],{"class":81}," { name: ",[68,573,574],{"class":564},"100",[68,576,577],{"class":81},", email: ",[68,579,580],{"class":564},"200",[68,582,583],{"class":81},", message: ",[68,585,586],{"class":564},"5000",[68,588,589],{"class":81}," };\n",[68,591,592,594,597,599,602,605,608,610,613,616,620,622,624,626,628,632,634,636,638,641,644],{"class":70,"line":119},[68,593,561],{"class":517},[68,595,596],{"class":564}," EMAIL",[68,598,568],{"class":517},[68,600,601],{"class":96}," \u002F",[68,603,604],{"class":517},"^",[68,606,607],{"class":564},"[",[68,609,604],{"class":517},[68,611,612],{"class":564},"\\s@]",[68,614,615],{"class":517},"+",[68,617,619],{"class":618},"sA_wV","@",[68,621,607],{"class":564},[68,623,604],{"class":517},[68,625,612],{"class":564},[68,627,615],{"class":517},[68,629,631],{"class":630},"snhLl","\\.",[68,633,607],{"class":564},[68,635,604],{"class":517},[68,637,612],{"class":564},[68,639,640],{"class":517},"{2,}$",[68,642,643],{"class":96},"\u002F",[68,645,646],{"class":81},";\n",[68,648,649],{"class":70,"line":143},[68,650,652],{"emptyLinePlaceholder":651},true,"\n",[68,654,655,658,660,663,666,669,673,676,679],{"class":70,"line":184},[68,656,657],{"class":517},"export",[68,659,480],{"class":517},[68,661,662],{"class":517}," function",[68,664,665],{"class":89}," onRequestPost",[68,667,668],{"class":81},"({ ",[68,670,672],{"class":671},"s4XuR","request",[68,674,675],{"class":81},", ",[68,677,678],{"class":671},"env",[68,680,681],{"class":81}," }) {\n",[68,683,684,687,690,692,695,698,701],{"class":70,"line":205},[68,685,686],{"class":517},"  const",[68,688,689],{"class":564}," f",[68,691,568],{"class":517},[68,693,694],{"class":517}," await",[68,696,697],{"class":81}," request.",[68,699,700],{"class":89},"formData",[68,702,703],{"class":81},"();\n",[68,705,706,708,711,713,716,719,722,725,728,731,734,737,740,743,746,749,752],{"class":70,"line":248},[68,707,686],{"class":517},[68,709,710],{"class":89}," get",[68,712,568],{"class":517},[68,714,715],{"class":81}," (",[68,717,718],{"class":671},"k",[68,720,721],{"class":81},") ",[68,723,724],{"class":517},"=>",[68,726,727],{"class":81}," (f.",[68,729,730],{"class":89},"get",[68,732,733],{"class":81},"(k) ",[68,735,736],{"class":517},"??",[68,738,739],{"class":96}," ''",[68,741,742],{"class":81},").",[68,744,745],{"class":89},"toString",[68,747,748],{"class":81},"().",[68,750,751],{"class":89},"trim",[68,753,703],{"class":81},[68,755,756,758,761,763,766,768,770,773,775,777,779],{"class":70,"line":269},[68,757,686],{"class":517},[68,759,760],{"class":564}," ip",[68,762,568],{"class":517},[68,764,765],{"class":81}," request.headers.",[68,767,730],{"class":89},[68,769,508],{"class":81},[68,771,772],{"class":96},"'cf-connecting-ip'",[68,774,721],{"class":81},[68,776,736],{"class":517},[68,778,739],{"class":96},[68,780,646],{"class":81},[68,782,783],{"class":70,"line":313},[68,784,652],{"emptyLinePlaceholder":651},[68,786,787],{"class":70,"line":366},[68,788,789],{"class":74},"  \u002F\u002F 1. cheap bot checks\n",[68,791,792,795,797,799,801,804,807,810,813,815,818,821],{"class":70,"line":395},[68,793,794],{"class":517},"  if",[68,796,715],{"class":81},[68,798,730],{"class":89},[68,800,508],{"class":81},[68,802,803],{"class":96},"'website'",[68,805,806],{"class":81},")) ",[68,808,809],{"class":517},"return",[68,811,812],{"class":89}," redirect",[68,814,508],{"class":81},[68,816,817],{"class":96},"'\u002Fcontact\u002Fthanks\u002F'",[68,819,820],{"class":81},");           ",[68,822,823],{"class":74},"\u002F\u002F honeypot: pretend success\n",[68,825,826,828,831,833,836,839,842,844,846,848,850,852,854,857,859,861,863,865,867],{"class":70,"line":432},[68,827,794],{"class":517},[68,829,830],{"class":81}," (Date.",[68,832,523],{"class":89},[68,834,835],{"class":81},"() ",[68,837,838],{"class":517},"-",[68,840,841],{"class":89}," Number",[68,843,508],{"class":81},[68,845,730],{"class":89},[68,847,508],{"class":81},[68,849,511],{"class":96},[68,851,806],{"class":81},[68,853,82],{"class":517},[68,855,856],{"class":564}," 3000",[68,858,721],{"class":81},[68,860,809],{"class":517},[68,862,812],{"class":89},[68,864,508],{"class":81},[68,866,817],{"class":96},[68,868,869],{"class":81},");\n",[68,871,872],{"class":70,"line":454},[68,873,652],{"emptyLinePlaceholder":651},[68,875,876],{"class":70,"line":464},[68,877,878],{"class":74},"  \u002F\u002F 2. validation\n",[68,880,881,883,886,888,890,892,894,897,900,902,904,907,910,912,914,917],{"class":70,"line":492},[68,882,686],{"class":517},[68,884,885],{"class":564}," data",[68,887,568],{"class":517},[68,889,571],{"class":81},[68,891,730],{"class":89},[68,893,508],{"class":81},[68,895,896],{"class":96},"'name'",[68,898,899],{"class":81},"), email: ",[68,901,730],{"class":89},[68,903,508],{"class":81},[68,905,906],{"class":96},"'email'",[68,908,909],{"class":81},"), message: ",[68,911,730],{"class":89},[68,913,508],{"class":81},[68,915,916],{"class":96},"'message'",[68,918,919],{"class":81},") };\n",[68,921,923,926,928,930,933,935,937,940,943,946,949,952,954,957,959,962,964,967,970,973,976,979,982,985,987,990,992,995,997,1000],{"class":70,"line":922},16,[68,924,925],{"class":517},"  for",[68,927,715],{"class":81},[68,929,561],{"class":517},[68,931,932],{"class":81}," [",[68,934,718],{"class":564},[68,936,675],{"class":81},[68,938,939],{"class":564},"max",[68,941,942],{"class":81},"] ",[68,944,945],{"class":517},"of",[68,947,948],{"class":81}," Object.",[68,950,951],{"class":89},"entries",[68,953,508],{"class":81},[68,955,956],{"class":564},"LIMIT",[68,958,806],{"class":81},[68,960,961],{"class":517},"if",[68,963,715],{"class":81},[68,965,966],{"class":517},"!",[68,968,969],{"class":81},"data[k] ",[68,971,972],{"class":517},"||",[68,974,975],{"class":81}," data[k].",[68,977,978],{"class":564},"length",[68,980,981],{"class":517}," >",[68,983,984],{"class":81}," max) ",[68,986,809],{"class":517},[68,988,989],{"class":89}," fail",[68,991,508],{"class":81},[68,993,994],{"class":96},"`Please check the ${",[68,996,718],{"class":81},[68,998,999],{"class":96},"} field.`",[68,1001,869],{"class":81},[68,1003,1005,1007,1009,1011,1014,1016,1019,1022,1024,1026,1028,1031],{"class":70,"line":1004},17,[68,1006,794],{"class":517},[68,1008,715],{"class":81},[68,1010,966],{"class":517},[68,1012,1013],{"class":564},"EMAIL",[68,1015,35],{"class":81},[68,1017,1018],{"class":89},"test",[68,1020,1021],{"class":81},"(data.email)) ",[68,1023,809],{"class":517},[68,1025,989],{"class":89},[68,1027,508],{"class":81},[68,1029,1030],{"class":96},"'Please enter a valid email address.'",[68,1032,869],{"class":81},[68,1034,1036],{"class":70,"line":1035},18,[68,1037,652],{"emptyLinePlaceholder":651},[68,1039,1041],{"class":70,"line":1040},19,[68,1042,1043],{"class":74},"  \u002F\u002F 3. rate limit: 5 per IP per hour\n",[68,1045,1047,1049,1052,1055,1058,1060,1062,1065,1068,1070,1073],{"class":70,"line":1046},20,[68,1048,686],{"class":517},[68,1050,1051],{"class":81}," { ",[68,1053,1054],{"class":564},"success",[68,1056,1057],{"class":81}," } ",[68,1059,93],{"class":517},[68,1061,694],{"class":517},[68,1063,1064],{"class":81}," env.",[68,1066,1067],{"class":564},"CONTACT_LIMITER",[68,1069,35],{"class":81},[68,1071,1072],{"class":89},"limit",[68,1074,1075],{"class":81},"({ key: ip });\n",[68,1077,1079,1081,1083,1085,1088,1090,1092,1094,1097,1099,1102],{"class":70,"line":1078},21,[68,1080,794],{"class":517},[68,1082,715],{"class":81},[68,1084,966],{"class":517},[68,1086,1087],{"class":81},"success) ",[68,1089,809],{"class":517},[68,1091,989],{"class":89},[68,1093,508],{"class":81},[68,1095,1096],{"class":96},"'Too many messages from this address. Please try again later.'",[68,1098,675],{"class":81},[68,1100,1101],{"class":564},"429",[68,1103,869],{"class":81},[68,1105,1107],{"class":70,"line":1106},22,[68,1108,652],{"emptyLinePlaceholder":651},[68,1110,1112],{"class":70,"line":1111},23,[68,1113,1114],{"class":74},"  \u002F\u002F 4. Turnstile\n",[68,1116,1118,1120,1123,1125,1127,1130,1132,1135],{"class":70,"line":1117},24,[68,1119,686],{"class":517},[68,1121,1122],{"class":564}," ts",[68,1124,568],{"class":517},[68,1126,694],{"class":517},[68,1128,1129],{"class":89}," fetch",[68,1131,508],{"class":81},[68,1133,1134],{"class":96},"'https:\u002F\u002Fchallenges.cloudflare.com\u002Fturnstile\u002Fv0\u002Fsiteverify'",[68,1136,1137],{"class":81},", {\n",[68,1139,1141,1144,1147],{"class":70,"line":1140},25,[68,1142,1143],{"class":81},"    method: ",[68,1145,1146],{"class":96},"'POST'",[68,1148,1149],{"class":81},",\n",[68,1151,1153,1156,1159,1162,1165,1168,1171,1173,1175,1178],{"class":70,"line":1152},26,[68,1154,1155],{"class":81},"    body: ",[68,1157,1158],{"class":517},"new",[68,1160,1161],{"class":89}," URLSearchParams",[68,1163,1164],{"class":81},"({ secret: env.",[68,1166,1167],{"class":564},"TURNSTILE_SECRET",[68,1169,1170],{"class":81},", response: ",[68,1172,730],{"class":89},[68,1174,508],{"class":81},[68,1176,1177],{"class":96},"'cf-turnstile-response'",[68,1179,1180],{"class":81},"), remoteip: ip }),\n",[68,1182,1184,1187,1190,1193,1196,1198,1200,1203,1206],{"class":70,"line":1183},27,[68,1185,1186],{"class":81},"  }).",[68,1188,1189],{"class":89},"then",[68,1191,1192],{"class":81},"((",[68,1194,1195],{"class":671},"r",[68,1197,721],{"class":81},[68,1199,724],{"class":517},[68,1201,1202],{"class":81}," r.",[68,1204,1205],{"class":89},"json",[68,1207,1208],{"class":81},"());\n",[68,1210,1212,1214,1216,1218,1221,1223,1225,1227,1230],{"class":70,"line":1211},28,[68,1213,794],{"class":517},[68,1215,715],{"class":81},[68,1217,966],{"class":517},[68,1219,1220],{"class":81},"ts.success) ",[68,1222,809],{"class":517},[68,1224,989],{"class":89},[68,1226,508],{"class":81},[68,1228,1229],{"class":96},"'Verification failed. Please try again.'",[68,1231,869],{"class":81},[68,1233,1235],{"class":70,"line":1234},29,[68,1236,652],{"emptyLinePlaceholder":651},[68,1238,1240],{"class":70,"line":1239},30,[68,1241,1242],{"class":74},"  \u002F\u002F 5. store first, then notify\n",[68,1244,1246,1248,1250,1252,1255,1258],{"class":70,"line":1245},31,[68,1247,686],{"class":517},[68,1249,108],{"class":564},[68,1251,568],{"class":517},[68,1253,1254],{"class":81}," crypto.",[68,1256,1257],{"class":89},"randomUUID",[68,1259,703],{"class":81},[68,1261,1263,1266,1268,1271,1273,1276,1278,1281],{"class":70,"line":1262},32,[68,1264,1265],{"class":517},"  await",[68,1267,1064],{"class":81},[68,1269,1270],{"class":564},"DB",[68,1272,35],{"class":81},[68,1274,1275],{"class":89},"prepare",[68,1277,508],{"class":81},[68,1279,1280],{"class":96},"'INSERT INTO messages (id, name, email, message, created) VALUES (?, ?, ?, ?, ?)'",[68,1282,1283],{"class":81},")\n",[68,1285,1287,1290,1293,1296,1298,1301,1303,1306,1309,1312],{"class":70,"line":1286},33,[68,1288,1289],{"class":81},"    .",[68,1291,1292],{"class":89},"bind",[68,1294,1295],{"class":81},"(id, data.name, data.email, data.message, ",[68,1297,1158],{"class":517},[68,1299,1300],{"class":89}," Date",[68,1302,748],{"class":81},[68,1304,1305],{"class":89},"toISOString",[68,1307,1308],{"class":81},"()).",[68,1310,1311],{"class":89},"run",[68,1313,703],{"class":81},[68,1315,1317,1319,1322,1325,1328,1331],{"class":70,"line":1316},34,[68,1318,794],{"class":517},[68,1320,1321],{"class":81}," (env.",[68,1323,1324],{"class":564},"ENVIRONMENT",[68,1326,1327],{"class":517}," ===",[68,1329,1330],{"class":96}," 'production'",[68,1332,1333],{"class":81},") {\n",[68,1335,1337,1340,1342,1344,1347],{"class":70,"line":1336},35,[68,1338,1339],{"class":517},"    await",[68,1341,1129],{"class":89},[68,1343,508],{"class":81},[68,1345,1346],{"class":96},"'https:\u002F\u002Fapi.email-provider.example\u002Fv1\u002Fsend'",[68,1348,1137],{"class":81},[68,1350,1352,1355,1357],{"class":70,"line":1351},36,[68,1353,1354],{"class":81},"      method: ",[68,1356,1146],{"class":96},[68,1358,1149],{"class":81},[68,1360,1362,1365,1368,1370,1372,1375,1378,1380,1383,1386,1389],{"class":70,"line":1361},37,[68,1363,1364],{"class":81},"      headers: { authorization: ",[68,1366,1367],{"class":96},"`Bearer ${",[68,1369,678],{"class":81},[68,1371,35],{"class":96},[68,1373,1374],{"class":564},"EMAIL_KEY",[68,1376,1377],{"class":96},"}`",[68,1379,675],{"class":81},[68,1381,1382],{"class":96},"'content-type'",[68,1384,1385],{"class":81},": ",[68,1387,1388],{"class":96},"'application\u002Fjson'",[68,1390,1391],{"class":81}," },\n",[68,1393,1395,1398,1401,1403,1406,1409,1412],{"class":70,"line":1394},38,[68,1396,1397],{"class":81},"      body: ",[68,1399,1400],{"class":564},"JSON",[68,1402,35],{"class":81},[68,1404,1405],{"class":89},"stringify",[68,1407,1408],{"class":81},"({ to: ",[68,1410,1411],{"class":96},"'docs-team@example.com'",[68,1413,1414],{"class":81},", reply_to: data.email,\n",[68,1416,1418,1421,1424,1427,1429,1432,1434,1437,1440,1442,1444,1447,1450,1453,1456,1458,1460,1462,1465,1467,1469,1472,1475,1478,1481,1484,1486],{"class":70,"line":1417},39,[68,1419,1420],{"class":81},"        subject: ",[68,1422,1423],{"class":96},"`Contact: ${",[68,1425,1426],{"class":81},"data",[68,1428,35],{"class":96},[68,1430,1431],{"class":81},"name",[68,1433,1377],{"class":96},[68,1435,1436],{"class":81},", text: ",[68,1438,1439],{"class":96},"`${",[68,1441,1426],{"class":81},[68,1443,35],{"class":96},[68,1445,1446],{"class":81},"message",[68,1448,1449],{"class":96},"}",[68,1451,1452],{"class":564},"\\n\\n",[68,1454,1455],{"class":96},"— ${",[68,1457,1426],{"class":81},[68,1459,35],{"class":96},[68,1461,1431],{"class":81},[68,1463,1464],{"class":96},"} \u003C${",[68,1466,1426],{"class":81},[68,1468,35],{"class":96},[68,1470,1471],{"class":81},"email",[68,1473,1474],{"class":96},"}>",[68,1476,1477],{"class":564},"\\n",[68,1479,1480],{"class":96},"ID ${",[68,1482,1483],{"class":81},"id",[68,1485,1377],{"class":96},[68,1487,1488],{"class":81}," }),\n",[68,1490,1492,1495,1498,1500,1502],{"class":70,"line":1491},40,[68,1493,1494],{"class":81},"      signal: AbortSignal.",[68,1496,1497],{"class":89},"timeout",[68,1499,508],{"class":81},[68,1501,586],{"class":564},[68,1503,1504],{"class":81},"),\n",[68,1506,1508,1511,1514,1517,1519,1522],{"class":70,"line":1507},41,[68,1509,1510],{"class":81},"    }).",[68,1512,1513],{"class":89},"catch",[68,1515,1516],{"class":81},"(() ",[68,1518,724],{"class":517},[68,1520,1521],{"class":81}," {});                                                 ",[68,1523,1524],{"class":74},"\u002F\u002F stored already; email is best effort\n",[68,1526,1528],{"class":70,"line":1527},42,[68,1529,1530],{"class":81},"  }\n",[68,1532,1534,1537,1539,1541,1543],{"class":70,"line":1533},43,[68,1535,1536],{"class":517},"  return",[68,1538,812],{"class":89},[68,1540,508],{"class":81},[68,1542,817],{"class":96},[68,1544,869],{"class":81},[68,1546,1548],{"class":70,"line":1547},44,[68,1549,1550],{"class":81},"}\n",[68,1552,1554],{"class":70,"line":1553},45,[68,1555,652],{"emptyLinePlaceholder":651},[68,1557,1559,1561,1563,1565,1567,1570,1572,1574,1577,1580,1582,1585,1588,1591],{"class":70,"line":1558},46,[68,1560,561],{"class":517},[68,1562,812],{"class":89},[68,1564,568],{"class":517},[68,1566,715],{"class":81},[68,1568,1569],{"class":671},"to",[68,1571,721],{"class":81},[68,1573,724],{"class":517},[68,1575,1576],{"class":517}," new",[68,1578,1579],{"class":89}," Response",[68,1581,508],{"class":81},[68,1583,1584],{"class":564},"null",[68,1586,1587],{"class":81},", { status: ",[68,1589,1590],{"class":564},"303",[68,1592,1593],{"class":81},", headers: { location: to } });\n",[68,1595,1597,1599,1601,1603,1605,1608,1610,1613,1615,1618,1620,1622,1624,1626],{"class":70,"line":1596},47,[68,1598,561],{"class":517},[68,1600,989],{"class":89},[68,1602,568],{"class":517},[68,1604,715],{"class":81},[68,1606,1607],{"class":671},"msg",[68,1609,675],{"class":81},[68,1611,1612],{"class":671},"status",[68,1614,568],{"class":517},[68,1616,1617],{"class":564}," 400",[68,1619,721],{"class":81},[68,1621,724],{"class":517},[68,1623,1576],{"class":517},[68,1625,1579],{"class":89},[68,1627,1628],{"class":81},"(\n",[68,1630,1632,1635,1637,1640],{"class":70,"line":1631},48,[68,1633,1634],{"class":96},"  `\u003C!doctype html>\u003Ctitle>Message not sent\u003C\u002Ftitle>\u003Cp>${",[68,1636,1607],{"class":81},[68,1638,1639],{"class":96},"}\u003C\u002Fp>\u003Cp>\u003Ca href=\"\u002Fcontact\u002F\">Back to the form\u003C\u002Fa>\u003C\u002Fp>`",[68,1641,1149],{"class":81},[68,1643,1645,1648,1650,1652,1655],{"class":70,"line":1644},49,[68,1646,1647],{"class":81},"  { status, headers: { ",[68,1649,1382],{"class":96},[68,1651,1385],{"class":81},[68,1653,1654],{"class":96},"'text\u002Fhtml; charset=utf-8'",[68,1656,1657],{"class":81}," } });\n",[14,1659,1660],{},"The order of checks runs from cheapest to most expensive: the honeypot and timing checks cost nothing, validation costs microseconds, the rate limiter a lookup, and Turnstile a network call. Bots that fail early never reach the database or the email provider. Honeypot and timing failures redirect to the thank-you page rather than returning an error, so bots learn nothing.",[1662,1663,1664,1827],"figure",{},[1665,1666,1673,1674,1673,1678,1673,1682,1673,1689,1673,1812],"svg",{"viewBox":1667,"role":1668,"ariaLabelledBy":1669,"xmlns":1672},"0 0 760 290","img",[1670,1671],"cfw-pipe-title","cfw-pipe-desc","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","\n  ",[1675,1676,1677],"title",{"id":1670},"Checks in the contact function, cheapest first",[1679,1680,1681],"desc",{"id":1671},"A submission passes through five stages: honeypot and timing, field validation, per-IP rate limit, Turnstile verification, then storage in D1 and an email notification. Failures at the first stage silently redirect to the thank-you page; failures at later stages return an error page. A successful submission redirects with a 303 to the thank-you page.",[1683,1684],"rect",{"x":1685,"y":1685,"width":1686,"height":1687,"fill":1688},"0","760","290","#ffffff",[1690,1691,1693,1694,1693,1702,1693,1713,1693,1719,1693,1725,1693,1728,1693,1732,1693,1735,1693,1741,1693,1745,1693,1748,1693,1753,1693,1757,1693,1760,1693,1765,1693,1769,1693,1772,1693,1791,1693,1795,1693,1798,1693,1801,1693,1803,1693,1808,1673],"g",{"style":1692},"font-family:system-ui, sans-serif;font-size:12px","\n    ",[1695,1696,1701],"text",{"x":1697,"y":1698,"fill":1699,"style":1700},"380","28","#1f2937","font-size:16px;font-weight:700;text-anchor:middle","Reject early, spend nothing on bots",[1683,1703],{"x":1704,"y":1705,"width":1706,"height":1707,"rx":1708,"fill":1709,"opacity":1710,"stroke":1711,"style":1712},"20","80","130","60","10","#8ac926","0.18","#5a8a16","stroke-width:1.5px",[1695,1714,1718],{"x":1715,"y":1716,"fill":1699,"style":1717},"85","106","font-weight:700;text-anchor:middle","honeypot",[1695,1720,1724],{"x":1715,"y":1721,"fill":1722,"style":1723},"124","#556071","font-size:11px;text-anchor:middle","+ 3 s timing",[1683,1726],{"x":1727,"y":1705,"width":1706,"height":1707,"rx":1708,"fill":1709,"opacity":1710,"stroke":1711,"style":1712},"165",[1695,1729,1731],{"x":1730,"y":1716,"fill":1699,"style":1717},"230","validate",[1695,1733,1734],{"x":1730,"y":1721,"fill":1722,"style":1723},"lengths, email",[1683,1736],{"x":1737,"y":1705,"width":1706,"height":1707,"rx":1708,"fill":1738,"opacity":1739,"stroke":1740,"style":1712},"310","#ffca3a","0.24","#a97b00",[1695,1742,1744],{"x":1743,"y":1716,"fill":1699,"style":1717},"375","rate limit",[1695,1746,1747],{"x":1743,"y":1721,"fill":1722,"style":1723},"5 \u002F IP \u002F hour",[1683,1749],{"x":1750,"y":1705,"width":1706,"height":1707,"rx":1708,"fill":1751,"opacity":1752,"stroke":1751,"style":1712},"455","#1982c4","0.14",[1695,1754,1756],{"x":1755,"y":1716,"fill":1699,"style":1717},"520","Turnstile",[1695,1758,1759],{"x":1755,"y":1721,"fill":1722,"style":1723},"siteverify",[1683,1761],{"x":1762,"y":1705,"width":1763,"height":1707,"rx":1708,"fill":1764,"opacity":1752,"stroke":1764,"style":1712},"600","140","#6a4c93",[1695,1766,1768],{"x":1767,"y":1716,"fill":1699,"style":1717},"670","D1 + email",[1695,1770,1771],{"x":1767,"y":1721,"fill":1722,"style":1723},"store, then notify",[1690,1773,1776,1777,1776,1782,1776,1785,1776,1788,1693],{"stroke":1722,"fill":1774,"style":1775},"none","stroke-width:2px","\n      ",[1778,1779],"path",{"d":1780,"style":1781},"M152 110 L161 110","marker-end:url(#cfw-arrow)",[1778,1783],{"d":1784,"style":1781},"M297 110 L306 110",[1778,1786],{"d":1787,"style":1781},"M442 110 L451 110",[1778,1789],{"d":1790,"style":1781},"M587 110 L596 110",[1695,1792,1794],{"x":1715,"y":1793,"fill":1722,"style":1723},"170","fake success",[1695,1796,1797],{"x":1730,"y":1793,"fill":1722,"style":1723},"400 page",[1695,1799,1800],{"x":1743,"y":1793,"fill":1722,"style":1723},"429 page",[1695,1802,1797],{"x":1755,"y":1793,"fill":1722,"style":1723},[1695,1804,1807],{"x":1767,"y":1793,"fill":1805,"style":1806},"#3f6410","font-size:11px;font-weight:700;text-anchor:middle","303 → \u002Fthanks\u002F",[1695,1809,1811],{"x":1697,"y":1810,"fill":1722,"style":1723},"232","Cost rises left to right: nothing, microseconds, a lookup, a network call, a write and an email",[1813,1814,1693,1815,1673],"defs",{},[1816,1817,1776,1824,1693],"marker",{"id":1818,"viewBox":1819,"refX":1820,"refY":1821,"markerWidth":1822,"markerHeight":1822,"orient":1823},"cfw-arrow","0 0 10 10","8","5","7","auto-start-reverse",[1778,1825],{"d":1826,"fill":1722},"M0 0 L10 5 L0 10 z",[1828,1829,1830],"figcaption",{},"Storing before emailing means a failed notification never loses a message.",[37,1832,1834],{"id":1833},"step-3-configuration-and-secrets","Step 3: Configuration and Secrets",[59,1836,1840],{"className":1837,"code":1838,"language":1839,"meta":64,"style":64},"language-toml shiki shiki-themes github-light github-dark","# wrangler.toml\nname = \"docs-site\"\npages_build_output_dir = \"dist\"\n\n[[d1_databases]]\nbinding = \"DB\"\ndatabase_name = \"docs-contact\"\ndatabase_id = \"…\"\n\n[[unsafe.bindings]]\nname = \"CONTACT_LIMITER\"\ntype = \"ratelimit\"\nnamespace_id = \"1001\"\nsimple = { limit = 5, period = 3600 }\n\n[vars]\nENVIRONMENT = \"production\"\n\n[env.preview.vars]\nENVIRONMENT = \"preview\"\n","toml",[18,1841,1842,1847,1852,1857,1861,1866,1871,1876,1881,1885,1890,1895,1900,1905,1910,1914,1919,1924,1928,1933],{"__ignoreMap":64},[68,1843,1844],{"class":70,"line":71},[68,1845,1846],{},"# wrangler.toml\n",[68,1848,1849],{"class":70,"line":78},[68,1850,1851],{},"name = \"docs-site\"\n",[68,1853,1854],{"class":70,"line":119},[68,1855,1856],{},"pages_build_output_dir = \"dist\"\n",[68,1858,1859],{"class":70,"line":143},[68,1860,652],{"emptyLinePlaceholder":651},[68,1862,1863],{"class":70,"line":184},[68,1864,1865],{},"[[d1_databases]]\n",[68,1867,1868],{"class":70,"line":205},[68,1869,1870],{},"binding = \"DB\"\n",[68,1872,1873],{"class":70,"line":248},[68,1874,1875],{},"database_name = \"docs-contact\"\n",[68,1877,1878],{"class":70,"line":269},[68,1879,1880],{},"database_id = \"…\"\n",[68,1882,1883],{"class":70,"line":313},[68,1884,652],{"emptyLinePlaceholder":651},[68,1886,1887],{"class":70,"line":366},[68,1888,1889],{},"[[unsafe.bindings]]\n",[68,1891,1892],{"class":70,"line":395},[68,1893,1894],{},"name = \"CONTACT_LIMITER\"\n",[68,1896,1897],{"class":70,"line":432},[68,1898,1899],{},"type = \"ratelimit\"\n",[68,1901,1902],{"class":70,"line":454},[68,1903,1904],{},"namespace_id = \"1001\"\n",[68,1906,1907],{"class":70,"line":464},[68,1908,1909],{},"simple = { limit = 5, period = 3600 }\n",[68,1911,1912],{"class":70,"line":492},[68,1913,652],{"emptyLinePlaceholder":651},[68,1915,1916],{"class":70,"line":922},[68,1917,1918],{},"[vars]\n",[68,1920,1921],{"class":70,"line":1004},[68,1922,1923],{},"ENVIRONMENT = \"production\"\n",[68,1925,1926],{"class":70,"line":1035},[68,1927,652],{"emptyLinePlaceholder":651},[68,1929,1930],{"class":70,"line":1040},[68,1931,1932],{},"[env.preview.vars]\n",[68,1934,1935],{"class":70,"line":1046},[68,1936,1937],{},"ENVIRONMENT = \"preview\"\n",[59,1939,1943],{"className":1940,"code":1941,"language":1942,"meta":64,"style":64},"language-bash shiki shiki-themes github-light github-dark","npx wrangler d1 execute docs-contact --remote --command \\\n  \"CREATE TABLE messages (id TEXT PRIMARY KEY, name TEXT, email TEXT, message TEXT, created TEXT)\"\nnpx wrangler pages secret put TURNSTILE_SECRET\nnpx wrangler pages secret put EMAIL_KEY\n","bash",[18,1944,1945,1971,1976,1994],{"__ignoreMap":64},[68,1946,1947,1950,1953,1956,1959,1962,1965,1968],{"class":70,"line":71},[68,1948,1949],{"class":89},"npx",[68,1951,1952],{"class":96}," wrangler",[68,1954,1955],{"class":96}," d1",[68,1957,1958],{"class":96}," execute",[68,1960,1961],{"class":96}," docs-contact",[68,1963,1964],{"class":564}," --remote",[68,1966,1967],{"class":564}," --command",[68,1969,1970],{"class":564}," \\\n",[68,1972,1973],{"class":70,"line":78},[68,1974,1975],{"class":96},"  \"CREATE TABLE messages (id TEXT PRIMARY KEY, name TEXT, email TEXT, message TEXT, created TEXT)\"\n",[68,1977,1978,1980,1982,1985,1988,1991],{"class":70,"line":119},[68,1979,1949],{"class":89},[68,1981,1952],{"class":96},[68,1983,1984],{"class":96}," pages",[68,1986,1987],{"class":96}," secret",[68,1989,1990],{"class":96}," put",[68,1992,1993],{"class":96}," TURNSTILE_SECRET\n",[68,1995,1996,1998,2000,2002,2004,2006],{"class":70,"line":143},[68,1997,1949],{"class":89},[68,1999,1952],{"class":96},[68,2001,1984],{"class":96},[68,2003,1987],{"class":96},[68,2005,1990],{"class":96},[68,2007,2008],{"class":96}," EMAIL_KEY\n",[14,2010,2011,2012,2014],{},"Secrets never appear in the repository or the build output. The ",[18,2013,1324],{}," variable keeps preview deploys from emailing the team: previews still exercise the whole function, including D1 writes to a preview database, but skip the notification.",[37,2016,2018],{"id":2017},"step-4-enhance-do-not-depend","Step 4: Enhance, Do Not Depend",[14,2020,2021,2022,2025,2026,2029],{},"With the server side complete, a few lines of script can improve the experience without making JavaScript a requirement. Intercept the submit event, send the same ",[18,2023,2024],{},"FormData"," with ",[18,2027,2028],{},"fetch",", and on a redirect response show an inline confirmation instead of navigating; on an error response, insert the server's message next to the form and move focus to it. If the script fails to load or throws, the browser simply performs the ordinary form post, and the reader still reaches the thank-you page.",[59,2031,2033],{"className":547,"code":2032,"language":549,"meta":64,"style":64},"const form = document.getElementById('contact');\nform.addEventListener('submit', async (e) => {\n  e.preventDefault();\n  const res = await fetch(form.action, { method: 'POST', body: new FormData(form), redirect: 'manual' });\n  const box = document.getElementById('form-status');\n  box.textContent = res.type === 'opaqueredirect' || res.ok ? 'Thanks — we reply within two working days.' : 'Something went wrong; please check the fields and try again.';\n  box.focus();\n});\n",[18,2034,2035,2056,2086,2096,2131,2151,2187,2197],{"__ignoreMap":64},[68,2036,2037,2039,2042,2044,2047,2049,2051,2054],{"class":70,"line":71},[68,2038,561],{"class":517},[68,2040,2041],{"class":564}," form",[68,2043,568],{"class":517},[68,2045,2046],{"class":81}," document.",[68,2048,505],{"class":89},[68,2050,508],{"class":81},[68,2052,2053],{"class":96},"'contact'",[68,2055,869],{"class":81},[68,2057,2058,2061,2064,2066,2069,2071,2074,2076,2079,2081,2083],{"class":70,"line":78},[68,2059,2060],{"class":81},"form.",[68,2062,2063],{"class":89},"addEventListener",[68,2065,508],{"class":81},[68,2067,2068],{"class":96},"'submit'",[68,2070,675],{"class":81},[68,2072,2073],{"class":517},"async",[68,2075,715],{"class":81},[68,2077,2078],{"class":671},"e",[68,2080,721],{"class":81},[68,2082,724],{"class":517},[68,2084,2085],{"class":81}," {\n",[68,2087,2088,2091,2094],{"class":70,"line":119},[68,2089,2090],{"class":81},"  e.",[68,2092,2093],{"class":89},"preventDefault",[68,2095,703],{"class":81},[68,2097,2098,2100,2103,2105,2107,2109,2112,2114,2117,2119,2122,2125,2128],{"class":70,"line":143},[68,2099,686],{"class":517},[68,2101,2102],{"class":564}," res",[68,2104,568],{"class":517},[68,2106,694],{"class":517},[68,2108,1129],{"class":89},[68,2110,2111],{"class":81},"(form.action, { method: ",[68,2113,1146],{"class":96},[68,2115,2116],{"class":81},", body: ",[68,2118,1158],{"class":517},[68,2120,2121],{"class":89}," FormData",[68,2123,2124],{"class":81},"(form), redirect: ",[68,2126,2127],{"class":96},"'manual'",[68,2129,2130],{"class":81}," });\n",[68,2132,2133,2135,2138,2140,2142,2144,2146,2149],{"class":70,"line":184},[68,2134,686],{"class":517},[68,2136,2137],{"class":564}," box",[68,2139,568],{"class":517},[68,2141,2046],{"class":81},[68,2143,505],{"class":89},[68,2145,508],{"class":81},[68,2147,2148],{"class":96},"'form-status'",[68,2150,869],{"class":81},[68,2152,2153,2156,2158,2161,2164,2167,2170,2173,2176,2179,2182,2185],{"class":70,"line":205},[68,2154,2155],{"class":81},"  box.textContent ",[68,2157,93],{"class":517},[68,2159,2160],{"class":81}," res.type ",[68,2162,2163],{"class":517},"===",[68,2165,2166],{"class":96}," 'opaqueredirect'",[68,2168,2169],{"class":517}," ||",[68,2171,2172],{"class":81}," res.ok ",[68,2174,2175],{"class":517},"?",[68,2177,2178],{"class":96}," 'Thanks — we reply within two working days.'",[68,2180,2181],{"class":517}," :",[68,2183,2184],{"class":96}," 'Something went wrong; please check the fields and try again.'",[68,2186,646],{"class":81},[68,2188,2189,2192,2195],{"class":70,"line":248},[68,2190,2191],{"class":81},"  box.",[68,2193,2194],{"class":89},"focus",[68,2196,703],{"class":81},[68,2198,2199],{"class":70,"line":269},[68,2200,2201],{"class":81},"});\n",[1662,2203,2204,2307],{},[1665,2205,1673,2210,1673,2213,1673,2216,1673,2219,1673,2300],{"viewBox":2206,"role":1668,"ariaLabelledBy":2207,"xmlns":1672},"0 0 760 240",[2208,2209],"cfw-pe-title","cfw-pe-desc",[1675,2211,2212],{"id":2208},"The same submission with and without JavaScript",[1679,2214,2215],{"id":2209},"Without JavaScript, the browser posts the form, receives a 303 redirect and loads the thank-you page. With JavaScript, a fetch posts the same data to the same endpoint, sees the redirect response and shows an inline message in a live region. Both paths reach the same function and the same outcome.",[1683,2217],{"x":1685,"y":1685,"width":1686,"height":2218,"fill":1688},"240",[1690,2220,1693,2221,1693,2224,1693,2230,1693,2239,1693,2245,1693,2248,1693,2252,1693,2257,1693,2261,1693,2265,1693,2268,1693,2272,1693,2274,1693,2276,1693,2278,1693,2281,1693,2296,1673],{"style":1692},[1695,2222,2223],{"x":1697,"y":1698,"fill":1699,"style":1700},"One endpoint, two ways to reach it",[1695,2225,2229],{"x":2226,"y":2227,"fill":1699,"style":2228},"30","84","font-weight:700","No JS",[1683,2231],{"x":1706,"y":2232,"width":2233,"height":2234,"rx":2235,"fill":2236,"stroke":2237,"style":2238},"64","160","34","6","#f8fafc","#d9e2ef","stroke-width:1px",[1695,2240,2244],{"x":2241,"y":2242,"fill":1699,"style":2243},"210","86","text-anchor:middle","form POST",[1683,2246],{"x":2247,"y":2232,"width":2233,"height":2234,"rx":2235,"fill":1764,"opacity":1752,"stroke":1764,"style":2238},"340",[1695,2249,2251],{"x":2250,"y":2242,"fill":1699,"style":2243},"420","\u002Fapi\u002Fcontact → 303",[1683,2253],{"x":2254,"y":2232,"width":2255,"height":2234,"rx":2235,"fill":1709,"opacity":2256,"stroke":1711,"style":2238},"550","180","0.2",[1695,2258,2260],{"x":2259,"y":2242,"fill":1699,"style":2243},"640","\u002Fcontact\u002Fthanks\u002F page",[1695,2262,2264],{"x":2226,"y":2263,"fill":1699,"style":2228},"164","With JS",[1683,2266],{"x":1706,"y":2267,"width":2233,"height":2234,"rx":2235,"fill":2236,"stroke":2237,"style":2238},"144",[1695,2269,2271],{"x":2241,"y":2270,"fill":1699,"style":2243},"166","fetch(FormData)",[1683,2273],{"x":2247,"y":2267,"width":2233,"height":2234,"rx":2235,"fill":1764,"opacity":1752,"stroke":1764,"style":2238},[1695,2275,2251],{"x":2250,"y":2270,"fill":1699,"style":2243},[1683,2277],{"x":2254,"y":2267,"width":2255,"height":2234,"rx":2235,"fill":1709,"opacity":2256,"stroke":1711,"style":2238},[1695,2279,2280],{"x":2259,"y":2270,"fill":1699,"style":2243},"inline live-region message",[1690,2282,1776,2283,1776,2287,1776,2290,1776,2293,1693],{"stroke":1722,"fill":1774,"style":1775},[1778,2284],{"d":2285,"style":2286},"M292 81 L336 81","marker-end:url(#cfw-pe-arrow)",[1778,2288],{"d":2289,"style":2286},"M502 81 L546 81",[1778,2291],{"d":2292,"style":2286},"M292 161 L336 161",[1778,2294],{"d":2295,"style":2286},"M502 161 L546 161",[1695,2297,2299],{"x":1697,"y":2298,"fill":1722,"style":1723},"216","The server never needs to know which path the reader took",[1813,2301,1693,2302,1673],{},[1816,2303,1776,2305,1693],{"id":2304,"viewBox":1819,"refX":1820,"refY":1821,"markerWidth":1822,"markerHeight":1822,"orient":1823},"cfw-pe-arrow",[1778,2306],{"d":1826,"fill":1722},[1828,2308,2309],{},"Enhancement changes only what the reader sees after a successful post, never whether the post can happen.",[14,2311,2312,2313,2316],{},"The status element should be ",[18,2314,2315],{},"\u003Cp id=\"form-status\" tabindex=\"-1\" role=\"status\">"," so screen readers announce the result and focus lands on it.",[37,2318,2320],{"id":2319},"step-5-retention-and-review","Step 5: Retention and Review",[14,2322,2323],{},"A contact form accumulates personal data. A scheduled Worker (cron trigger) deletes messages older than 180 days:",[59,2325,2327],{"className":547,"code":2326,"language":549,"meta":64,"style":64},"export default {\n  async scheduled(_, env) {\n    await env.DB.prepare(\"DELETE FROM messages WHERE created \u003C datetime('now', '-180 days')\").run();\n  },\n};\n",[18,2328,2329,2338,2357,2380,2385],{"__ignoreMap":64},[68,2330,2331,2333,2336],{"class":70,"line":71},[68,2332,657],{"class":517},[68,2334,2335],{"class":517}," default",[68,2337,2085],{"class":81},[68,2339,2340,2343,2346,2348,2351,2353,2355],{"class":70,"line":78},[68,2341,2342],{"class":517},"  async",[68,2344,2345],{"class":89}," scheduled",[68,2347,508],{"class":81},[68,2349,2350],{"class":671},"_",[68,2352,675],{"class":81},[68,2354,678],{"class":671},[68,2356,1333],{"class":81},[68,2358,2359,2361,2363,2365,2367,2369,2371,2374,2376,2378],{"class":70,"line":119},[68,2360,1339],{"class":517},[68,2362,1064],{"class":81},[68,2364,1270],{"class":564},[68,2366,35],{"class":81},[68,2368,1275],{"class":89},[68,2370,508],{"class":81},[68,2372,2373],{"class":96},"\"DELETE FROM messages WHERE created \u003C datetime('now', '-180 days')\"",[68,2375,742],{"class":81},[68,2377,1311],{"class":89},[68,2379,703],{"class":81},[68,2381,2382],{"class":70,"line":143},[68,2383,2384],{"class":81},"  },\n",[68,2386,2387],{"class":70,"line":184},[68,2388,2389],{"class":81},"};\n",[14,2391,2392,2393,2397],{},"State the retention period under the form. For the team, a small protected page — behind Cloudflare Access, as in ",[26,2394,2396],{"href":2395},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fprotecting-a-static-site-behind-authentication\u002F","Protecting a Static Site Behind Authentication"," — can list recent messages straight from D1 for when an email goes astray.",[37,2399,2401],{"id":2400},"measured-impact","Measured Impact",[14,2403,2404],{},"Four weeks after replacing an embedded form widget with this function:",[2406,2407,2408,2424],"table",{},[2409,2410,2411],"thead",{},[2412,2413,2414,2418,2421],"tr",{},[2415,2416,2417],"th",{},"Measure",[2415,2419,2420],{},"Embedded widget",[2415,2422,2423],{},"Worker function",[2425,2426,2427,2439,2450,2461,2472,2482,2493],"tbody",{},[2412,2428,2429,2433,2436],{},[2430,2431,2432],"td",{},"JavaScript on contact page",[2430,2434,2435],{},"148 KB",[2430,2437,2438],{},"11 KB (Turnstile, async)",[2412,2440,2441,2444,2447],{},[2430,2442,2443],{},"Contact page LCP (mobile, Lighthouse)",[2430,2445,2446],{},"2.7 s",[2430,2448,2449],{},"1.2 s",[2412,2451,2452,2455,2458],{},[2430,2453,2454],{},"CLS",[2430,2456,2457],{},"0.19",[2430,2459,2460],{},"0.00",[2412,2462,2463,2466,2469],{},[2430,2464,2465],{},"Legitimate submissions",[2430,2467,2468],{},"49",[2430,2470,2471],{},"63",[2412,2473,2474,2477,2479],{},[2430,2475,2476],{},"Spam reaching the team",[2430,2478,1821],{},[2430,2480,2481],{},"2",[2412,2483,2484,2487,2490],{},[2430,2485,2486],{},"Function latency p50 \u002F p99",[2430,2488,2489],{},"—",[2430,2491,2492],{},"38 ms \u002F 190 ms (incl. Turnstile verify)",[2412,2494,2495,2498,2501],{},[2430,2496,2497],{},"Monthly cost",[2430,2499,2500],{},"29 USD (widget plan)",[2430,2502,2503],{},"0 USD (free tiers)",[1662,2505,2506,2570],{},[1665,2507,1673,2512,1673,2515,1673,2518,1673,2521],{"viewBox":2508,"role":1668,"ariaLabelledBy":2509,"xmlns":1672},"0 0 760 260",[2510,2511],"cfw-lat-title","cfw-lat-desc",[1675,2513,2514],{"id":2510},"Where the function's time goes",[1679,2516,2517],{"id":2511},"A stacked bar of a median 38 millisecond submission: 1 millisecond of validation, 2 milliseconds for the rate limiter, 21 milliseconds for Turnstile verification, 9 milliseconds for the D1 write, and 5 milliseconds for dispatching the email request.",[1683,2519],{"x":1685,"y":1685,"width":1686,"height":2520,"fill":1688},"260",[1690,2522,1693,2523,1693,2526,1693,2531,1693,2535,1693,2540,1693,2545,1693,2548,1693,2552,1693,2557,1693,2561,1693,2566,1673],{"style":1692},[1695,2524,2525],{"x":1697,"y":1698,"fill":1699,"style":1700},"Median submission: 38 ms end to end",[1683,2527],{"x":1707,"y":1705,"width":2528,"height":2529,"fill":1709,"opacity":2530,"stroke":1711,"style":2238},"16","44","0.4",[1683,2532],{"x":2533,"y":1705,"width":2534,"height":2529,"fill":1738,"opacity":2530,"stroke":1740,"style":2238},"76","32",[1683,2536],{"x":2537,"y":1705,"width":2538,"height":2529,"fill":1751,"opacity":2539,"stroke":1751,"style":2238},"108","336","0.25",[1695,2541,2544],{"x":2542,"y":2543,"fill":1699,"style":2243},"276","107","Turnstile verify · 21 ms",[1683,2546],{"x":2547,"y":1705,"width":2267,"height":2529,"fill":1764,"opacity":2539,"stroke":1764,"style":2238},"444",[1695,2549,2551],{"x":2550,"y":2543,"fill":1699,"style":2243},"516","D1 write · 9 ms",[1683,2553],{"x":2554,"y":1705,"width":1705,"height":2529,"fill":2555,"opacity":2256,"stroke":2556,"style":2238},"588","#ff595e","#d83b41",[1695,2558,2560],{"x":2559,"y":2543,"fill":1699,"style":1723},"628","email 5",[1695,2562,2565],{"x":1707,"y":2563,"fill":1722,"style":2564},"146","font-size:11px","validate 1 · limit 2",[1695,2567,2569],{"x":1697,"y":2568,"fill":1722,"style":1723},"196","Worker timing via performance.now() spans, logged to Workers Analytics Engine, 4 weeks",[1828,2571,2572],{},"Turnstile verification dominates; everything the site itself does takes about 17 ms.",[37,2574,2576],{"id":2575},"pitfalls-rollback","Pitfalls & Rollback",[42,2578,2579,2586,2592,2598,2604,2610,2616],{},[45,2580,2581,2585],{},[2582,2583,2584],"strong",{},"Returning errors for honeypot hits."," Bots adapt to error messages; pretend success instead.",[45,2587,2588,2591],{},[2582,2589,2590],{},"Emailing before storing."," An email API outage then loses messages. Store first.",[45,2593,2594,2597],{},[2582,2595,2596],{},"No timeout on the email call."," A slow provider would hold the reader on a spinning submit; set a timeout and treat email as best effort.",[45,2599,2600,2603],{},[2582,2601,2602],{},"Real emails from previews."," Gate notifications on an environment variable.",[45,2605,2606,2609],{},[2582,2607,2608],{},"Echoing input unescaped."," The error page above interpolates only fixed messages; if you ever echo the reader's input back, escape it, or the form becomes a reflected-XSS vector.",[45,2611,2612,2615],{},[2582,2613,2614],{},"Trusting the reply-to address."," Anyone can type any email. Never auto-send confirmations to it without rate limits, or the form becomes a way to email third parties through your domain.",[45,2617,2618,2621,2622,2625],{},[2582,2619,2620],{},"Rollback:"," point the form's ",[18,2623,2624],{},"action"," back at the previous handler, or delete the function file; the static site is unaffected either way.",[37,2627,2629],{"id":2628},"conclusion","Conclusion",[14,2631,2632],{},"A contact form on Cloudflare is one function file, a D1 table, a rate-limit binding and a Turnstile widget — all deployed with the site and all within free tiers at typical volumes. Ordering the checks from cheapest to most expensive keeps bots from costing anything, storing before emailing keeps messages safe, and a retention job keeps the data from piling up. Replacing an embedded widget with it halved the contact page's LCP, removed its layout shift and cut spam to two messages in four weeks.",[37,2634,2636],{"id":2635},"faq","FAQ",[2638,2639,2641],"h3",{"id":2640},"does-the-form-work-without-javascript","Does the form work without JavaScript?",[14,2643,2644],{},"Yes. It is a normal HTML form that posts to the function and receives a redirect to a thank-you page. JavaScript only adds the Turnstile widget and an inline success message; without it, the server skips nothing except the inline message, and Turnstile falls back to a non-interactive check where possible.",[2638,2646,2648],{"id":2647},"how-are-emails-sent-from-a-worker","How are emails sent from a Worker?",[14,2650,2651],{},"Through an email API over HTTPS, or Cloudflare's Email Workers send binding for addresses verified in Email Routing. A Worker cannot open SMTP connections on port 25, so a transactional email provider's HTTP API is the common choice.",[2638,2653,2655],{"id":2654},"why-store-submissions-in-d1-as-well-as-emailing-them","Why store submissions in D1 as well as emailing them?",[14,2657,2658],{},"Email can fail or be filtered. Writing each submission to a database first means nothing is lost if the email step fails, and it gives you a place to apply a retention policy.",[2638,2660,2662],{"id":2661},"how-much-does-this-cost","How much does this cost?",[14,2664,2665],{},"For a typical contact form, nothing beyond the free tiers: Workers requests, D1 storage and Turnstile are all free at low volume. The email provider may have its own free allowance.",[37,2667,2669],{"id":2668},"related","Related",[42,2671,2672,2681,2686,2693,2700],{},[45,2673,2674,2677,2678,2680],{},[2582,2675,2676],{},"Parent:"," ",[26,2679,34],{"href":33}," — what functions are for on a static site.",[45,2682,2683,2685],{},[26,2684,29],{"href":28}," — comparing this with other approaches.",[45,2687,2688,2692],{},[26,2689,2691],{"href":2690},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fnetlify-functions-vs-cloudflare-workers\u002F","Netlify Functions vs Cloudflare Workers"," — the same handler on Netlify.",[45,2694,2695,2699],{},[26,2696,2698],{"href":2697},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup\u002Fautomating-eleventy-deployments-with-cloudflare-pages\u002F","Automating Eleventy Deployments with Cloudflare Pages"," — deploying the site the function ships with.",[45,2701,2702,2706],{},[26,2703,2705],{"href":2704},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fwriting-a-content-security-policy-for-a-static-site\u002F","Writing a Content Security Policy for a Static Site"," — allowing Turnstile in the policy.",[2708,2709,2710],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s9eBZ, html code.shiki .s9eBZ{--shiki-default:#22863A;--shiki-dark:#85E89D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sA_wV, html code.shiki .sA_wV{--shiki-default:#032F62;--shiki-dark:#DBEDFF}html pre.shiki code .snhLl, html code.shiki .snhLl{--shiki-default:#22863A;--shiki-default-font-weight:bold;--shiki-dark:#85E89D;--shiki-dark-font-weight:bold}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":64,"searchDepth":78,"depth":78,"links":2712},[2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2728],{"id":39,"depth":78,"text":40},{"id":56,"depth":78,"text":57},{"id":543,"depth":78,"text":544},{"id":1833,"depth":78,"text":1834},{"id":2017,"depth":78,"text":2018},{"id":2319,"depth":78,"text":2320},{"id":2400,"depth":78,"text":2401},{"id":2575,"depth":78,"text":2576},{"id":2628,"depth":78,"text":2629},{"id":2635,"depth":78,"text":2636,"children":2723},[2724,2725,2726,2727],{"id":2640,"depth":119,"text":2641},{"id":2647,"depth":119,"text":2648},{"id":2654,"depth":119,"text":2655},{"id":2661,"depth":119,"text":2662},{"id":2668,"depth":78,"text":2669},[2730,2732,2735,2736],{"name":2731,"item":643},"Home",{"name":2733,"item":2734},"Production-Ready Deployment & CI\u002FCD Workflows","\u002Fproduction-ready-deployment-cicd-workflows\u002F",{"name":34,"item":33},{"name":5,"item":2737},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fadding-a-contact-form-with-cloudflare-workers\u002F","2026-09-18","Build a contact form for a static site on Cloudflare: a Pages Function that validates, checks Turnstile, rate-limits, stores in D1 and emails the team.","md",[2742,2743,2744,2745],{"q":2641,"a":2644},{"q":2648,"a":2651},{"q":2655,"a":2658},{"q":2662,"a":2746},{"For a typical contact form, nothing beyond the free tiers":2747},"Workers requests, D1 storage and Turnstile are all free at low volume. The email provider may have its own free allowance.",{},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fadding-a-contact-form-with-cloudflare-workers",{"title":5,"description":2739},"production-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fadding-a-contact-form-with-cloudflare-workers\u002Findex","article","baCd6pHd3Sn5hVIvIhY8NbJ1qd3NjvgYPm4p0eijw1A",[2755,2758,2761,2764,2767,2770,2773,2776,2779,2782,2785,2788,2791,2794,2797,2800,2803,2806,2809,2812,2815,2818,2821,2824,2827,2830,2833,2836,2839,2842,2845,2848,2851,2854,2857,2860,2863,2866,2869,2872,2875,2878,2881,2884,2887,2890,2893,2896,2899,2902,2905,2908,2911,2914,2917,2920,2923,2926,2929,2932,2935,2938,2941,2944,2947,2950,2953,2956,2959,2962,2965,2968,2971,2974,2977,2980,2983,2986,2989,2992,2995,2998,3001,3004,3007,3010,3013,3016,3019,3022,3025,3028,3031,3034,3037,3040,3043,3046,3049,3052,3055,3058,3061,3064,3067,3070,3073,3076,3079,3082,3085,3088,3091,3094,3097,3100,3103,3106,3109,3112,3115,3118,3121,3124,3127,3130,3133,3136,3139,3142,3145,3148,3151,3154,3157,3160,3163,3166,3169,3172,3175,3178,3181,3184,3187,3190,3193,3196,3199,3202,3205,3208,3211,3214,3217,3220,3223,3226,3229,3232,3235,3238,3241,3244,3247,3250,3253,3256,3259,3262,3264,3267,3270,3273,3276,3279,3282,3285,3286,3288,3290,3292,3294],{"path":2756,"title":2757},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fastro-vs-eleventy-for-documentation-sites\u002Fastro-vs-eleventy-build-times-at-10000-pages","Astro vs Eleventy Build Times at 10,000 Pages",{"path":2759,"title":2760},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fastro-vs-eleventy-for-documentation-sites\u002Fchoosing-between-astro-and-eleventy-for-large-docs","Astro vs Eleventy for Large Docs (1000+ Pages)",{"path":2762,"title":2763},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fastro-vs-eleventy-for-documentation-sites\u002Fcontent-collections-vs-eleventy-data-cascade","Content Collections vs the Eleventy Data Cascade",{"path":2765,"title":2766},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fastro-vs-eleventy-for-documentation-sites","Astro vs Eleventy for Documentation Sites",{"path":2768,"title":2769},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fastro-vs-eleventy-for-documentation-sites\u002Fshortcodes-vs-components-for-docs-authors","Shortcodes vs Components for Docs Authors",{"path":2771,"title":2772},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fastro-vs-eleventy-for-documentation-sites\u002Fsidebar-navigation-in-astro-and-eleventy","Sidebar Navigation in Astro and Eleventy",{"path":2774,"title":2775},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress\u002Fcustomizing-starlight-without-forking-the-theme","Customizing Starlight Without Forking the Theme",{"path":2777,"title":2778},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress\u002Fdocusaurus-vs-starlight-for-product-documentation","Docusaurus vs Starlight for Product Documentation",{"path":2780,"title":2781},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress","Docs Frameworks: Docusaurus, Starlight and VitePress",{"path":2783,"title":2784},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress\u002Fmdx-vs-markdoc-for-docs-content","MDX vs Markdoc for Docs Content",{"path":2786,"title":2787},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress\u002Fmigrating-from-mkdocs-to-starlight","Migrating from MkDocs to Starlight",{"path":2789,"title":2790},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress\u002Fversioned-documentation-with-docusaurus","Versioned Documentation with Docusaurus",{"path":2792,"title":2793},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fdocs-frameworks-docusaurus-starlight-vitepress\u002Fvitepress-for-library-documentation","VitePress for Library Documentation",{"path":2795,"title":2796},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fhugo-build-times-for-large-repositories\u002Fhow-to-benchmark-hugo-vs-astro-build-speeds","How to Benchmark Hugo vs Astro Build Speeds",{"path":2798,"title":2799},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fhugo-build-times-for-large-repositories\u002Fhugo-partialcached-for-faster-builds","Hugo partialCached for Faster Builds",{"path":2801,"title":2802},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fhugo-build-times-for-large-repositories","Hugo Build Times for Large Repositories",{"path":2804,"title":2805},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fhugo-build-times-for-large-repositories\u002Fprofiling-hugo-templates-with-template-metrics","Profiling Hugo Templates With Template Metrics",{"path":2807,"title":2808},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fhugo-build-times-for-large-repositories\u002Freducing-hugo-memory-usage-on-ci-runners","Reducing Hugo Memory Usage on CI Runners",{"path":2810,"title":2811},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fhugo-build-times-for-large-repositories\u002Fspeeding-up-hugo-builds-with-render-hooks-and-caching","Speeding Up Hugo Builds with Render Hooks & Caching",{"path":2813,"title":2814},"\u002Fchoosing-the-right-static-site-generator-for-production","Choosing the Right Static Site Generator for Production",{"path":2816,"title":2817},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fjekyll-plugin-ecosystem\u002Feleventy-vs-jekyll-for-markdown-heavy-blogs","Eleventy vs Jekyll for Markdown-Heavy Blogs",{"path":2819,"title":2820},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fjekyll-plugin-ecosystem","Jekyll Plugin Ecosystem",{"path":2822,"title":2823},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fjekyll-plugin-ecosystem\u002Freplacing-jekyll-plugins-when-migrating-to-eleventy","Replacing Jekyll Plugins When Migrating to Eleventy",{"path":2825,"title":2826},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fjekyll-plugin-ecosystem\u002Frunning-jekyll-on-github-pages-without-plugins","Running Jekyll on GitHub Pages Without Plugins",{"path":2828,"title":2829},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fjekyll-plugin-ecosystem\u002Fspeeding-up-slow-jekyll-builds","Speeding Up Slow Jekyll Builds",{"path":2831,"title":2832},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fjekyll-plugin-ecosystem\u002Fupgrading-jekyll-and-ruby-versions-safely","Upgrading Jekyll and Ruby Versions Safely",{"path":2834,"title":2835},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fconverting-front-matter-at-scale-during-migration","Converting Front Matter at Scale During Migration",{"path":2837,"title":2838},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators","Migrating Between Static Site Generators",{"path":2840,"title":2841},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fkeeping-redirects-working-after-an-ssg-migration","Keeping Redirects Working After an SSG Migration",{"path":2843,"title":2844},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fmigrating-a-docs-site-from-jekyll-to-hugo","Migrating a Docs Site From Jekyll to Hugo",{"path":2846,"title":2847},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fmigrating-from-gatsby-to-astro","Migrating from Gatsby to Astro",{"path":2849,"title":2850},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fmigrating-from-hugo-to-astro-without-breaking-urls","Migrating From Hugo to Astro Without Breaking URLs",{"path":2852,"title":2853},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fmigrating-wordpress-to-a-static-site-generator","Migrating WordPress to a Static Site Generator",{"path":2855,"title":2856},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fmigrating-between-static-site-generators\u002Fporting-shortcodes-and-includes-between-generators","Porting Shortcodes and Includes Between Generators",{"path":2858,"title":2859},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fnextjs-static-export-for-content-sites\u002Fhandling-dynamic-routes-in-nextjs-static-export","Handling Dynamic Routes in Next.js Static Export",{"path":2861,"title":2862},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fnextjs-static-export-for-content-sites","Next.js Static Export for Content Sites",{"path":2864,"title":2865},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fnextjs-static-export-for-content-sites\u002Fmigrating-from-gatsby-to-nextjs-static-export","Migrating from Gatsby to Next.js Static Export",{"path":2867,"title":2868},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fnextjs-static-export-for-content-sites\u002Fnextjs-app-router-static-export-limitations","Next.js App Router Static Export Limitations",{"path":2870,"title":2871},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fnextjs-static-export-for-content-sites\u002Fnextjs-static-export-vs-astro-for-marketing-sites","Next.js Static Export vs Astro for Marketing",{"path":2873,"title":2874},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fnextjs-static-export-for-content-sites\u002Foptimizing-images-in-nextjs-static-export","Optimizing Images in Next.js Static Export",{"path":2876,"title":2877},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites\u002Fadding-pagefind-to-an-astro-site","Adding Pagefind to an Astro Site",{"path":2879,"title":2880},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites\u002Fbuilding-a-lunr-index-at-build-time-in-eleventy","Building a Lunr Index at Build Time in Eleventy",{"path":2882,"title":2883},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites","Search for Static Sites",{"path":2885,"title":2886},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites\u002Findexing-hugo-sites-with-pagefind","Indexing Hugo Sites with Pagefind",{"path":2888,"title":2889},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites\u002Fmultilingual-search-on-static-sites","Multilingual Search on Static Sites",{"path":2891,"title":2892},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites\u002Fpagefind-vs-algolia-docsearch","Pagefind vs Algolia DocSearch",{"path":2894,"title":2895},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fsearch-for-static-sites\u002Fsearch-index-size-budgets-for-large-docs","Search Index Size Budgets for Large Docs",{"path":2897,"title":2898},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix\u002Fbest-ssg-for-technical-writers-without-coding-experience","Best SSG for Non-Developer Technical Writers",{"path":2900,"title":2901},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix\u002Fchoosing-an-ssg-for-api-reference-documentation","Choosing an SSG for API Reference Documentation",{"path":2903,"title":2904},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix\u002Fevaluating-ssg-accessibility-defaults","Evaluating SSG Accessibility Defaults",{"path":2906,"title":2907},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix","SSG Framework Selection Matrix",{"path":2909,"title":2910},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix\u002Fpicking-an-ssg-for-a-multi-language-documentation-site","Picking an SSG for a Multi-Language Docs Site",{"path":2912,"title":2913},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix\u002Fssg-selection-checklist-for-engineering-teams","SSG Selection Checklist for Engineering Teams",{"path":2915,"title":2916},"\u002Fchoosing-the-right-static-site-generator-for-production\u002Fssg-framework-selection-matrix\u002Ftotal-cost-of-ownership-for-static-site-generators","Total Cost of Ownership for Static Site Generators",{"path":2918,"title":2919},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcdn-caching-rules-for-ssgs\u002Fcache-busting-with-content-hashed-filenames","Cache Busting with Content-Hashed Filenames",{"path":2921,"title":2922},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcdn-caching-rules-for-ssgs","CDN Caching Rules for SSGs",{"path":2924,"title":2925},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcdn-caching-rules-for-ssgs\u002Fpurging-the-cdn-cache-after-a-static-deploy","Purging the CDN Cache After a Static Deploy",{"path":2927,"title":2928},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcdn-caching-rules-for-ssgs\u002Fsetting-cache-control-headers-on-cloudflare-pages","Cache-Control Headers on Cloudflare Pages",{"path":2930,"title":2931},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcdn-caching-rules-for-ssgs\u002Fsetting-up-proper-cache-headers-on-netlify","Proper Cache Headers on Netlify for SSGs",{"path":2933,"title":2934},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcdn-caching-rules-for-ssgs\u002Fstale-while-revalidate-for-static-html","Stale-While-Revalidate for Static HTML",{"path":2936,"title":2937},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites\u002Feliminating-layout-shift-from-web-fonts","Eliminating Layout Shift From Web Fonts",{"path":2939,"title":2940},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites\u002Ffixing-cls-from-cookie-banners","Fixing CLS from Cookie Banners",{"path":2942,"title":2943},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites\u002Ffixing-cls-from-late-loading-embeds","Fixing CLS From Late-Loading Embeds",{"path":2945,"title":2946},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites\u002Ffixing-cls-from-sticky-headers-and-anchor-links","Fixing CLS from Sticky Headers and Anchor Links",{"path":2948,"title":2949},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites","Cumulative Layout Shift Fixes for Static Sites",{"path":2951,"title":2952},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites\u002Fmeasuring-cls-in-the-field-with-web-vitals-js","Measuring CLS in the Field With web-vitals.js",{"path":2954,"title":2955},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fcumulative-layout-shift-fixes-for-static-sites\u002Freserving-space-for-images-and-embeds-to-stop-layout-shift","Reserving Space for Images and Embeds",{"path":2957,"title":2958},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Ffont-loading-strategies-for-static-sites\u002Ffont-display-optional-vs-swap","font-display: optional vs swap",{"path":2960,"title":2961},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Ffont-loading-strategies-for-static-sites","Font Loading Strategies for Static Sites",{"path":2963,"title":2964},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Ffont-loading-strategies-for-static-sites\u002Fmetric-matched-fallback-fonts-with-size-adjust","Metric-Matched Fallback Fonts with size-adjust",{"path":2966,"title":2967},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Ffont-loading-strategies-for-static-sites\u002Fpreloading-fonts-without-double-downloads","Preloading Fonts Without Double Downloads",{"path":2969,"title":2970},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Ffont-loading-strategies-for-static-sites\u002Fself-hosting-google-fonts-to-eliminate-layout-shift","Self-Host Google Fonts to Eliminate Layout Shift",{"path":2972,"title":2973},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Ffont-loading-strategies-for-static-sites\u002Fsubsetting-variable-fonts-for-faster-first-render","Subsetting Variable Fonts for Faster First Render",{"path":2975,"title":2976},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro\u002Fbuilding-an-image-cdn-pipeline-for-static-sites","Building an Image CDN Pipeline for Static Sites",{"path":2978,"title":2979},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro\u002Fgenerating-open-graph-images-at-build-time","Generating Open Graph Images at Build Time",{"path":2981,"title":2982},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro","Image Optimization Pipelines in Astro",{"path":2984,"title":2985},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro\u002Flazy-loading-images-without-hurting-lcp","Lazy-Loading Images Without Hurting LCP",{"path":2987,"title":2988},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro\u002Foptimizing-webp-images-in-hugo-without-plugins","Optimizing WebP Images in Hugo Without Plugins",{"path":2990,"title":2991},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro\u002Fresponsive-images-with-srcset-in-eleventy","Responsive Images with srcset in Eleventy",{"path":2993,"title":2994},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fimage-optimization-pipelines-in-astro\u002Fserving-avif-with-fallbacks-on-static-sites","Serving AVIF With Fallbacks on Static Sites",{"path":2996,"title":2997},"\u002Fperformance-optimization-core-web-vitals-for-ssgs","Core Web Vitals Optimization for SSGs",{"path":2999,"title":3000},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fjavascript-hydration-partial-rendering\u002Fastro-islands-vs-full-hydration-performance","Astro Islands vs Full Hydration Performance",{"path":3002,"title":3003},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fjavascript-hydration-partial-rendering\u002Fdeferring-hydration-with-client-visible-in-astro","Deferring Hydration with client:visible in Astro",{"path":3005,"title":3006},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fjavascript-hydration-partial-rendering\u002Fhow-to-reduce-bundle-size-in-eleventy-builds","How to Reduce Bundle Size in Eleventy Builds",{"path":3008,"title":3009},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fjavascript-hydration-partial-rendering","JavaScript Hydration & Partial Rendering",{"path":3011,"title":3012},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fjavascript-hydration-partial-rendering\u002Fmeasuring-inp-on-static-sites-with-real-user-monitoring","Measuring INP on Static Sites with RUM",{"path":3014,"title":3015},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fjavascript-hydration-partial-rendering\u002Freplacing-react-islands-with-web-components","Replacing React Islands with Web Components",{"path":3017,"title":3018},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Flargest-contentful-paint-optimization-for-static-sites\u002Feliminating-render-blocking-css-on-static-sites","Eliminating Render-Blocking CSS on Static Sites",{"path":3020,"title":3021},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Flargest-contentful-paint-optimization-for-static-sites\u002Ffixing-lcp-on-text-heavy-documentation-pages","Fixing LCP on Text-Heavy Documentation Pages",{"path":3023,"title":3024},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Flargest-contentful-paint-optimization-for-static-sites","Largest Contentful Paint Optimization for Static Sites",{"path":3026,"title":3027},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Flargest-contentful-paint-optimization-for-static-sites\u002Fmeasuring-lcp-subparts-with-devtools","Measuring LCP Subparts with DevTools",{"path":3029,"title":3030},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Flargest-contentful-paint-optimization-for-static-sites\u002Foptimizing-lcp-on-astro-with-priority-hints","Optimizing LCP on Astro with Priority Hints",{"path":3032,"title":3033},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Flargest-contentful-paint-optimization-for-static-sites\u002Freducing-lcp-from-hero-images-on-static-sites","Reducing LCP from Hero Images on Static Sites",{"path":3035,"title":3036},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci\u002Fcomparing-lab-and-field-data-with-crux","Comparing Lab and Field Data with CrUX",{"path":3038,"title":3039},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci","Performance Budgets and Lighthouse CI",{"path":3041,"title":3042},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci\u002Freducing-lighthouse-score-variance-in-ci","Reducing Lighthouse Score Variance in CI",{"path":3044,"title":3045},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci\u002Frunning-webpagetest-scripts-against-preview-deploys","Running WebPageTest Scripts Against Preview Deploys",{"path":3047,"title":3048},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci\u002Fsetting-up-lighthouse-ci-for-a-static-site","Setting Up Lighthouse CI for a Static Site",{"path":3050,"title":3051},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci\u002Ftracking-bundle-size-per-pull-request","Tracking Bundle Size per Pull Request",{"path":3053,"title":3054},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fperformance-budgets-and-lighthouse-ci\u002Fwriting-a-performance-budget-that-fails-builds","Writing a Performance Budget That Fails Builds",{"path":3056,"title":3057},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fresource-hints-and-navigation-speed\u002Fauditing-unused-preloads","Auditing Unused Preloads",{"path":3059,"title":3060},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fresource-hints-and-navigation-speed","Resource Hints and Navigation Speed",{"path":3062,"title":3063},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fresource-hints-and-navigation-speed\u002Finstant-navigation-with-speculation-rules","Instant Navigation with Speculation Rules",{"path":3065,"title":3066},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fresource-hints-and-navigation-speed\u002Fpreconnect-vs-dns-prefetch-on-static-sites","Preconnect vs DNS-Prefetch on Static Sites",{"path":3068,"title":3069},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fresource-hints-and-navigation-speed\u002Fprefetching-links-in-astro","Prefetching Links in Astro",{"path":3071,"title":3072},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fresource-hints-and-navigation-speed\u002Fview-transitions-on-multi-page-static-sites","View Transitions on Multi-Page Static Sites",{"path":3074,"title":3075},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fthird-party-script-performance-on-static-sites\u002Fauditing-third-party-scripts-with-lighthouse","Auditing Third-Party Scripts With Lighthouse",{"path":3077,"title":3078},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fthird-party-script-performance-on-static-sites","Third-Party Script Performance on Static Sites",{"path":3080,"title":3081},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fthird-party-script-performance-on-static-sites\u002Flazy-loading-youtube-embeds-on-static-sites","Lazy-Loading YouTube Embeds on Static Sites",{"path":3083,"title":3084},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fthird-party-script-performance-on-static-sites\u002Floading-google-tag-manager-without-hurting-inp","Loading Google Tag Manager Without Hurting INP",{"path":3086,"title":3087},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fthird-party-script-performance-on-static-sites\u002Frunning-third-party-scripts-in-a-web-worker-with-partytown","Running Third-Party Scripts in a Web Worker with Partytown",{"path":3089,"title":3090},"\u002Fperformance-optimization-core-web-vitals-for-ssgs\u002Fthird-party-script-performance-on-static-sites\u002Fself-hosting-analytics-to-cut-third-party-requests","Self-Hosting Analytics to Cut Third-Party Requests",{"path":3092,"title":3093},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup\u002Fautomating-eleventy-deployments-with-cloudflare-pages","Automating Eleventy Deployments on Cloudflare Pages",{"path":3095,"title":3096},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup\u002Fconfiguring-redirects-on-cloudflare-pages","Configuring Redirects on Cloudflare Pages",{"path":3098,"title":3099},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup\u002Fcustom-domains-and-tls-on-cloudflare-pages","Custom Domains and TLS on Cloudflare Pages",{"path":3101,"title":3102},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup\u002Fdeploying-hugo-to-cloudflare-pages-and-workers","Deploying Hugo to Cloudflare Pages and Workers",{"path":3104,"title":3105},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup","Cloudflare Pages Edge Caching Setup",{"path":3107,"title":3108},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcloudflare-pages-edge-caching-setup\u002Fmigrating-from-cloudflare-pages-to-workers-static-assets","Migrating from Cloudflare Pages to Workers Static Assets",{"path":3110,"title":3111},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcontent-workflows-for-documentation-teams\u002Fchecking-links-in-pull-requests","Checking Links in Pull Requests",{"path":3113,"title":3114},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcontent-workflows-for-documentation-teams\u002Fdocs-as-code-review-workflow-for-writers","Docs-as-Code Review Workflow for Writers",{"path":3116,"title":3117},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcontent-workflows-for-documentation-teams\u002Feditorial-checks-with-vale-in-ci","Editorial Checks with Vale in CI",{"path":3119,"title":3120},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcontent-workflows-for-documentation-teams","Content Workflows for Documentation Teams",{"path":3122,"title":3123},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcontent-workflows-for-documentation-teams\u002Fscheduling-content-publication-with-cron-triggered-builds","Scheduling Content Publication With Cron-Triggered Builds",{"path":3125,"title":3126},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fcontent-workflows-for-documentation-teams\u002Fwiring-a-headless-cms-to-a-static-build","Wiring a Headless CMS to a Static Build",{"path":3128,"title":3129},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds\u002Fbuilding-astro-sites-with-github-actions","Building Astro Sites with GitHub Actions",{"path":3131,"title":3132},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds\u002Fcaching-node-modules-in-github-actions-for-faster-ssg-builds","Caching node_modules in GitHub Actions",{"path":3134,"title":3135},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds\u002Fdeploying-to-github-pages-with-actions","Deploying to GitHub Pages with Actions",{"path":3137,"title":3138},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds\u002Fdeploying-to-multiple-environments-from-one-workflow","Deploying to Multiple Environments From One Workflow",{"path":3140,"title":3141},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds\u002Fhow-to-set-up-github-actions-for-hugo-deployments","GitHub Actions for Hugo Deployments",{"path":3143,"title":3144},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds","GitHub Actions for Automated SSG Builds",{"path":3146,"title":3147},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fgithub-actions-for-automated-ssg-builds\u002Fmatrix-builds-for-multi-site-monorepos","Matrix Builds for Multi-Site Monorepos",{"path":3149,"title":3150},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs\u002Fcaching-hugo-builds-in-github-actions","Caching Hugo Builds in GitHub Actions",{"path":3152,"title":3153},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs\u002Fenabling-incremental-builds-in-eleventy","Enabling Incremental Builds in Eleventy",{"path":3155,"title":3156},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs\u002Fincremental-builds-in-astro-with-the-content-layer","Incremental Builds in Astro with the Content Layer",{"path":3158,"title":3159},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs","Incremental Builds and Build Caching for SSGs",{"path":3161,"title":3162},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs\u002Fmeasuring-build-time-regressions-in-ci","Measuring Build-Time Regressions in CI",{"path":3164,"title":3165},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs\u002Fremote-caching-with-turborepo-for-ssg-monorepos","Remote Caching with Turborepo for SSG Monorepos",{"path":3167,"title":3168},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fincremental-builds-and-build-caching-for-ssgs\u002Fsharing-build-cache-across-ci-runners","Sharing Build Cache Across CI Runners",{"path":3170,"title":3171},"\u002Fproduction-ready-deployment-cicd-workflows","Production-Ready Deployment & CI\u002FCD for SSGs",{"path":3173,"title":3174},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fmonitoring-static-sites-in-production\u002Falerting-on-cache-hit-ratio-drops","Alerting on Cache Hit Ratio Drops",{"path":3176,"title":3177},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fmonitoring-static-sites-in-production\u002Fbuilding-a-core-web-vitals-dashboard-from-rum-data","Building a Core Web Vitals Dashboard from RUM Data",{"path":3179,"title":3180},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fmonitoring-static-sites-in-production\u002Fcrawling-for-broken-links-on-a-schedule","Crawling for Broken Links on a Schedule",{"path":3182,"title":3183},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fmonitoring-static-sites-in-production","Monitoring Static Sites in Production",{"path":3185,"title":3186},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fmonitoring-static-sites-in-production\u002Flogging-404s-at-the-edge","Logging 404s at the Edge",{"path":3188,"title":3189},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fmonitoring-static-sites-in-production\u002Fuptime-and-synthetic-checks-for-static-sites","Uptime and Synthetic Checks for Static Sites",{"path":3191,"title":3192},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fnetlify-vs-vercel-deployment-strategies\u002Fconfiguring-vercel-for-hugo-and-eleventy","Configuring Vercel for Hugo and Eleventy",{"path":3194,"title":3195},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fnetlify-vs-vercel-deployment-strategies","Netlify vs Vercel Deployment Strategies",{"path":3197,"title":3198},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fnetlify-vs-vercel-deployment-strategies\u002Fnetlify-build-hooks-for-content-updates","Netlify Build Hooks for Content Updates",{"path":3200,"title":3201},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fnetlify-vs-vercel-deployment-strategies\u002Fnetlify-redirects-and-rewrites-for-static-sites","Netlify Redirects and Rewrites for Static Sites",{"path":3203,"title":3204},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fnetlify-vs-vercel-deployment-strategies\u002Fsetting-up-deploy-previews-on-netlify-for-every-pull-request","Netlify Deploy Previews for Every Pull Request",{"path":3206,"title":3207},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fnetlify-vs-vercel-deployment-strategies\u002Fvercel-isr-vs-static-generation-for-ssgs","Vercel ISR vs Static Generation for SSGs",{"path":3209,"title":3210},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fpreview-environments-for-pull-requests\u002Fautomating-preview-deploy-pipelines-with-github-actions","Automating Preview Deploy Pipelines with GitHub Actions",{"path":3212,"title":3213},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fpreview-environments-for-pull-requests\u002Fcleaning-up-stale-preview-deployments","Cleaning Up Stale Preview Deployments",{"path":3215,"title":3216},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fpreview-environments-for-pull-requests","Preview Environments for Pull Requests",{"path":3218,"title":3219},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fpreview-environments-for-pull-requests\u002Fpassword-protecting-preview-deployments","Password-Protecting Preview Deployments",{"path":3221,"title":3222},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fpreview-environments-for-pull-requests\u002Fpreviewing-headless-cms-drafts","Previewing Headless CMS Drafts",{"path":3224,"title":3225},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fpreview-environments-for-pull-requests\u002Fvisual-regression-testing-on-preview-deploys","Visual Regression Testing on Preview Deploys",{"path":3227,"title":3228},"\u002Fproduction-ready-deployment-cicd-workflows\u002Frollbacks-and-deploy-safety-for-static-sites\u002Fatomic-deploys-vs-incremental-uploads","Atomic Deploys vs Incremental Uploads",{"path":3230,"title":3231},"\u002Fproduction-ready-deployment-cicd-workflows\u002Frollbacks-and-deploy-safety-for-static-sites\u002Fcanary-releases-for-static-sites","Canary Releases for Static Sites",{"path":3233,"title":3234},"\u002Fproduction-ready-deployment-cicd-workflows\u002Frollbacks-and-deploy-safety-for-static-sites\u002Ffeature-flags-on-static-sites","Feature Flags on Static Sites",{"path":3236,"title":3237},"\u002Fproduction-ready-deployment-cicd-workflows\u002Frollbacks-and-deploy-safety-for-static-sites","Rollbacks and Deploy Safety for Static Sites",{"path":3239,"title":3240},"\u002Fproduction-ready-deployment-cicd-workflows\u002Frollbacks-and-deploy-safety-for-static-sites\u002Frolling-back-a-bad-static-deploy-in-under-a-minute","Rolling Back a Bad Static Deploy in Under a Minute",{"path":3242,"title":3243},"\u002Fproduction-ready-deployment-cicd-workflows\u002Frollbacks-and-deploy-safety-for-static-sites\u002Frunning-smoke-tests-against-a-preview-url","Running Smoke Tests Against a Preview URL",{"path":3245,"title":3246},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fauditing-npm-dependencies-in-ssg-pipelines","Auditing npm Dependencies in SSG Pipelines",{"path":3248,"title":3249},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fenabling-hsts-and-preload-safely","Enabling HSTS and Preload Safely",{"path":3251,"title":3252},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fhash-based-csp-for-inline-scripts-in-astro","Hash-Based CSP for Inline Scripts in Astro",{"path":3254,"title":3255},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites","Security Headers and Hardening for Static Sites",{"path":3257,"title":3258},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fsecuring-deploy-credentials-with-github-oidc","Securing Deploy Credentials with GitHub OIDC",{"path":3260,"title":3261},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fsubresource-integrity-for-third-party-assets","Subresource Integrity for Third-Party Assets",{"path":3263,"title":2705},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fsecurity-headers-for-static-sites\u002Fwriting-a-content-security-policy-for-a-static-site",{"path":3265,"title":3266},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites\u002Fclean-urls-and-trailing-slashes-on-s3","Clean URLs and Trailing Slashes on S3",{"path":3268,"title":3269},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites\u002Fcloudfront-functions-for-redirects","CloudFront Functions for Redirects",{"path":3271,"title":3272},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites\u002Fdeploying-a-static-site-to-s3-and-cloudfront","Deploying a Static Site to S3 and CloudFront",{"path":3274,"title":3275},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites","Self-Hosting Static Sites on S3, Nginx and Caddy",{"path":3277,"title":3278},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites\u002Fserving-a-static-site-with-caddy","Serving a Static Site with Caddy",{"path":3280,"title":3281},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites\u002Fserving-a-static-site-with-nginx","Serving a Static Site with Nginx",{"path":3283,"title":3284},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fself-hosting-static-sites\u002Fzero-downtime-deploys-with-symlink-swaps","Zero-Downtime Deploys with Symlink Swaps",{"path":2749,"title":5},{"path":3287,"title":29},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fhandling-form-submissions-on-a-static-site",{"path":3289,"title":34},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites",{"path":3291,"title":2691},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fnetlify-functions-vs-cloudflare-workers",{"path":3293,"title":2396},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fprotecting-a-static-site-behind-authentication",{"path":3295,"title":3296},"\u002Fproduction-ready-deployment-cicd-workflows\u002Fserverless-functions-for-static-sites\u002Fproxying-third-party-apis-from-an-edge-function","Proxying Third-Party APIs from an Edge Function",1789722847982]