<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Harvis</title>
    <description>The latest articles on DEV Community by Harvis (harvis).</description>
    <link>https://dev.to/harvis</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F14367%2F8a78bd71-0f70-40d2-b896-1faf359efbf2.png</url>
      <title>DEV Community: Harvis</title>
      <link>https://dev.to/harvis</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/harvis"/>
    <language>en</language>
    <item>
      <title>A static site that collects form submissions, in one HTML attribute</title>
      <dc:creator>Andrius Putna</dc:creator>
      <pubDate>Thu, 13 Aug 2026 12:50:05 +0000</pubDate>
      <link>https://dev.to/harvis/a-static-site-that-collects-form-submissions-in-one-html-attribute-2cln</link>
      <guid>https://dev.to/harvis/a-static-site-that-collects-form-submissions-in-one-html-attribute-2cln</guid>
      <description>&lt;p&gt;A static site has no backend. That is the point of one — and it is also why the contact form is the first thing that breaks. The usual answers are a third-party form service with its own signup, a serverless function you now maintain, or a &lt;code&gt;mailto:&lt;/code&gt; link nobody clicks.&lt;/p&gt;

&lt;p&gt;There is a third option that falls out of how static hosting already works: the host is in the path of every HTML response it serves. It can collect the form itself.&lt;/p&gt;

&lt;p&gt;On &lt;a href="https://harvis.dev" rel="noopener noreferrer"&gt;harvis.dev&lt;/a&gt; that is one attribute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;harvis-form=&lt;/span&gt;&lt;span class="s"&gt;"contact"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&amp;gt;&lt;/span&gt;Send&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deploy, and submissions show up in the dashboard. No script tag, no API key in the page, no &lt;code&gt;fetch()&lt;/code&gt;, no JavaScript at all — the form works with JS disabled, because it is a plain HTML form doing what plain HTML forms have always done.&lt;/p&gt;

&lt;p&gt;The page I am describing is live at &lt;strong&gt;&lt;a href="https://harvis-forms-example.harvis.dev/" rel="noopener noreferrer"&gt;harvis-forms-example.harvis.dev&lt;/a&gt;&lt;/strong&gt; — submit the form and see where you land. Everything below is what makes that page work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What actually happens
&lt;/h2&gt;

&lt;p&gt;The rewrite happens on the way out, while the HTML is being served:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;action&lt;/code&gt; and &lt;code&gt;method&lt;/code&gt; are replaced with &lt;code&gt;/__harvis/form/contact&lt;/code&gt; on your site's own subdomain.
Same origin, so there is no CORS, no preflight, and nothing in the page has to know a project id.&lt;/li&gt;
&lt;li&gt;A honeypot field is inserted. It is positioned off-screen rather than &lt;code&gt;display: none&lt;/code&gt;, because a
bot that skips hidden inputs is a bot that would otherwise get through. Anything that fills it in gets the success page and is stored nowhere — a bot that can tell it was caught is a bot that tries again differently.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data-harvis-redirect="/thanks.html"&lt;/code&gt; becomes a hidden field, since the handler never sees your
HTML — only what the browser posts. It is re-validated on arrival, and a protocol-relative &lt;code&gt;//somewhere-else&lt;/code&gt; is refused.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The reply is a &lt;strong&gt;303&lt;/strong&gt;, so the browser follows it with a &lt;code&gt;GET&lt;/code&gt; and a refresh on the thank-you page cannot post the form twice.&lt;/p&gt;

&lt;p&gt;The form name is part of a URL and a dashboard heading, so it has to match &lt;code&gt;[a-z0-9][a-z0-9_-]{0,39}&lt;/code&gt;. Anything else — including a bare &lt;code&gt;harvis-form&lt;/code&gt; with no value — collects under &lt;code&gt;default&lt;/code&gt;. Two forms on one page, two named inboxes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;harvis-form=&lt;/span&gt;&lt;span class="s"&gt;"contact"&lt;/span&gt; &lt;span class="na"&gt;data-harvis-redirect=&lt;/span&gt;&lt;span class="s"&gt;"/thanks.html"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;…&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;harvis-form=&lt;/span&gt;&lt;span class="s"&gt;"newsletter"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;…&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The second one has no redirect, so it lands on a branded thank-you page the host serves.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one case where the attribute does nothing
&lt;/h2&gt;

&lt;p&gt;The rewrite runs over the response body, so it only sees markup that is already in the file. A form that React, Vue or Svelte mounts at runtime has no &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; in the served HTML — the marker never matches and nothing is rewritten. Write the endpoint yourself instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/__harvis/form/contact"&lt;/span&gt; &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_harvis_redirect"&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"/thanks"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* …your fields… */&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;form&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The receiving side does not care who wrote those fields. Drop the &lt;code&gt;harvis-form&lt;/code&gt; attribute when you do this, or a prerendered page gets rewritten twice and ends up with two honeypots.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The page: &lt;strong&gt;&lt;a href="https://harvis-forms-example.harvis.dev/" rel="noopener noreferrer"&gt;https://harvis-forms-example.harvis.dev/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The complete source — two forms, the deploy script, the workflow — is here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/harvis-io/solutions/tree/main/forms-example" rel="noopener noreferrer"&gt;https://github.com/harvis-io/solutions/tree/main/forms-example&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Three files of site, no build step, no dependencies. Clone it, run &lt;code&gt;HARVIS_API_KEY=hvs_… ./deploy.sh public&lt;/code&gt;, and you have a static page with a working contact form about two seconds later.&lt;/p&gt;

&lt;p&gt;Here is the served HTML of that live page, which is the shortest version of this whole post:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- what is in the repo --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;harvis-form=&lt;/span&gt;&lt;span class="s"&gt;"contact"&lt;/span&gt; &lt;span class="na"&gt;data-harvis-redirect=&lt;/span&gt;&lt;span class="s"&gt;"/thanks.html"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- what the browser receives --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;harvis-form=&lt;/span&gt;&lt;span class="s"&gt;"contact"&lt;/span&gt; &lt;span class="na"&gt;data-harvis-redirect=&lt;/span&gt;&lt;span class="s"&gt;"/thanks.html"&lt;/span&gt;
      &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/__harvis/form/contact"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"post"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>showdev</category>
      <category>html</category>
      <category>github</category>
    </item>
  </channel>
</rss>
