<?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: Richest Country</title>
    <description>The latest articles on DEV Community by Richest Country (@richestcountry).</description>
    <link>https://dev.to/richestcountry</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%2Fuser%2Fprofile_image%2F4253110%2Fe66f538f-e703-4a59-8e93-1086353216dd.jpg</url>
      <title>DEV Community: Richest Country</title>
      <link>https://dev.to/richestcountry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/richestcountry"/>
    <language>en</language>
    <item>
      <title>How to add a contact form to a static site without Formspree or Netlify Forms</title>
      <dc:creator>Richest Country</dc:creator>
      <pubDate>Thu, 19 Nov 2026 06:26:59 +0000</pubDate>
      <link>https://dev.to/richestcountry/how-to-add-a-contact-form-to-a-static-site-without-formspree-or-netlify-forms-1421</link>
      <guid>https://dev.to/richestcountry/how-to-add-a-contact-form-to-a-static-site-without-formspree-or-netlify-forms-1421</guid>
      <description>&lt;p&gt;A static site is easy until someone needs to write to you.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mailto:&lt;/code&gt; leaks your address to scrapers. A Google Form looks like a Google Form. And the usual next step — Formspree, Basin, Netlify Forms, a serverless function plus a database — is either a monthly bill or a small project of its own.&lt;/p&gt;

&lt;p&gt;You can host a tiny form backend yourself. This post walks through a working setup: a plain HTML form, a Node.js endpoint with no npm dependencies, a honeypot, and an inbox that is just a file on disk.&lt;/p&gt;

&lt;p&gt;The finished starter is called Formbox Lite. It is free and MIT licensed. You can follow along and write it yourself, or clone the repo at the end and run &lt;code&gt;node server.js&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The form on your site
&lt;/h3&gt;

&lt;p&gt;No JavaScript required:&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;action&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://forms.yourdomain.com/f/contact"&lt;/span&gt; &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;Name &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;Email &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&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;&amp;lt;/label&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&amp;gt;&lt;/span&gt;Message &lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"message"&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/textarea&amp;gt;&amp;lt;/label&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_gotcha"&lt;/span&gt; &lt;span class="na"&gt;tabindex&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"-1"&lt;/span&gt; &lt;span class="na"&gt;autocomplete&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"off"&lt;/span&gt;
         &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"position:absolute;left:-8000px"&lt;/span&gt; &lt;span class="na"&gt;aria-hidden&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"true"&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;type&lt;/span&gt;&lt;span class="o"&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="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_next"&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&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;button&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&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;The &lt;code&gt;_gotcha&lt;/code&gt; field is a honeypot. People never see it. A lot of bots still fill every input they find. If that field is not empty, the server should pretend the submit worked and then throw the message away.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;_next&lt;/code&gt; is where the browser goes after a successful HTML submit. The server must only redirect to a path on your own origin, or you have built an open redirect.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. A server that only does one thing
&lt;/h3&gt;

&lt;p&gt;You do not need Express for this. Node's built-in &lt;code&gt;http&lt;/code&gt; module is enough:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;POST /f/contact&lt;/code&gt; accepts &lt;code&gt;application/x-www-form-urlencoded&lt;/code&gt; or &lt;code&gt;application/json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reject an empty body&lt;/li&gt;
&lt;li&gt;Reject the honeypot (with a fake success)&lt;/li&gt;
&lt;li&gt;Rate-limit by a hash of the client address — do not store raw IPs&lt;/li&gt;
&lt;li&gt;Append a JSON object to &lt;code&gt;data/submissions.jsonl&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Redirect to &lt;code&gt;/thanks.html&lt;/code&gt;, or return &lt;code&gt;{ ok: true, id }&lt;/code&gt; if the client asked for JSON&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JSON Lines is an underrated database for a contact form. You can read it with any editor, back it up by copying one file, and grep it when you need to. You only outgrow it when you have many forms, search, or notifications — not on day one.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. An inbox you can actually open
&lt;/h3&gt;

&lt;p&gt;A raw &lt;code&gt;.jsonl&lt;/code&gt; file works, but a &lt;code&gt;/inbox&lt;/code&gt; page is nicer when you are testing. On localhost it can be open. In production, put a password in front of it and serve it over HTTPS.&lt;/p&gt;

&lt;p&gt;That is the whole product for a personal site: form, endpoint, file, inbox.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. What this does not do (yet)
&lt;/h3&gt;

&lt;p&gt;A one-form starter will not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;email you when a message arrives&lt;/li&gt;
&lt;li&gt;post to Slack or a CRM&lt;/li&gt;
&lt;li&gt;run captcha or a serious spam model&lt;/li&gt;
&lt;li&gt;manage ten forms for ten sites&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you need those, you are in "real form backend" territory. I also make a fuller kit for that. For a single contact page, the lite server is enough.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Run it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# download the zip from the link above and unzip it&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; formbox-lite
node server.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;a href="http://127.0.0.1:3000" rel="noopener noreferrer"&gt;http://127.0.0.1:3000&lt;/a&gt;, send a message, then open /inbox. There is a short go-live checklist in the README (HOST, PUBLIC_URL, ALLOWED_ORIGIN, INBOX_PASSWORD, a persistent disk).&lt;/p&gt;

&lt;p&gt;Download (free, pay-what-you-want): &lt;a href="https://richestcountry.gumroad.com/l/formbox-lite" rel="noopener noreferrer"&gt;https://richestcountry.gumroad.com/l/formbox-lite&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want the multi-form dashboard, spam filtering, SMTP and signed webhooks: &lt;a href="https://richestcountry.gumroad.com/l/yiutjv" rel="noopener noreferrer"&gt;Formbox Kit&lt;/a&gt; ($19).&lt;/p&gt;

&lt;p&gt;Questions and patches are welcome. Tell me what broke when you put it in front of a real site.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
