Introduction
I decided some time ago to move away from using Netlify for my sites, as I didn’t want to be tied into a particular hosting service - regardless of what nice features that provider provided.
The one feature that I missed was having a form-handling server so I could have contact forms built into my site instead of linking to another site or paying extra to another service to handle forms for me. So, I decided to build my own, creatively titled static-forms
.
Official Repo and GitHub Mirror
Current feature set:
- CORS compatibility
- Multiple handlers per form
- Specific allowed domains per handler
- Custom honeypot fields
- Handler types:
- Email (SMTP and
sendmail
)- Define to, from, (b)cc, subject, and body as Go templates with access to the form submission’s contents.
- Email (SMTP and
- Template functions:
-
FormValue
: get first value of named input from form -
FormValues
: get all values of named input from form as[]string
-
Errorf
: Throw an error that gets returned and displayed to the form submitter
-
- TOML configuration files with support for including files from another directory.
- Live reloading on configuration file change with fallback to old config if parsing fails
-
Docker image in development (
sendmail
handler needs special setup)
Notes
Here’s a link to the javascript used in my theme BluestNight to submit the form and display client errors to the user.
The server is still in beta and doesn’t have a versioned release yet, but I’ve been using it for a few weeks now on my sites without any observed issues. It’s also structured to be (somewhat) usable as an API in other Go server software, e.g. so people can define their own form handlers without forking the project.
Documentation hasn’t been assembled quite yet, but I can provide examples to people looking to test their own copy.
Finally, the email handler is the only one right now, but I plan to create others as needs arise, such as automatic git issue creation and a database backend with a frontend for viewing all form submissions - I have other things to work on right now, so those are on the back burner for the time being.