Wynglet

Form Submissions

Accept form submissions from your static site with built-in CSRF token protection, rate limiting, and spam detection.

Check out a live example right here within the documentation!

Overview

Wynglet provides a secure form submission API that allows your static site visitors to submit data without requiring a backend.

Features:

Getting Started

Step 1: Generate a Token

Before users can submit a form, you need to generate a CSRF token. This is typically done when the page loads.

fetch('https://wynglet.your-server.com/forms/v1/token', {
  method: 'GET'
})
.then(response => response.json())
.then(data => {
  document.getElementById('token').value = data.token;
})

Step 2: Create Your Form

Create a form on your page that includes:

<form method="POST" action="https://wynglet.your-server.com/forms/v1/submit">
  
  <input type="hidden" name="_token" id="token" value="">

  
  <input type="hidden" name="_form_id" value="contact-form">

  
  <input type="hidden" name="_subject" value="New Contact Form Submission">

  
  <input type="hidden" name="_redirect" value="https://your-site.com/thank-you">

  
  <input type="hidden" name="_honeypot" value="">

  
  <input type="text" name="name" placeholder="Your name" required>
  <input type="email" name="email" placeholder="Your email" required>
  <textarea name="message" placeholder="Your message" required></textarea>

  <button type="submit">Send</button>
</form>

Step 3: Handle Form Data

Form submissions are validated and stored in the Wynglet database. You can view them in the Dashboard.

Security

To prevent abuse and to conserve resources, Wynglet blocks all domains by default, until you explicitly authorize each domain you care about.

Manage your authorized domains in the Dashboard.

Rate Limiting

To prevent spam:

These limits help ensure quality submissions while preventing spam.

Spam Detection

Honeypot Fields

The _honeypot field is a hidden field that should always be empty. If it contains data, the submission is likely automated spam and is rejected.


<input type="hidden" name="_honeypot" value="">

CORS Validation

Requests must come from authorized domains. Requests from unrecognized origins are rejected.

Form ID Validation

Each form submission must include a valid _form_id that has been previously registered.

Configuration

Configure form handling in your wynglet.yml:

forms:
  rate-limit:
    per-ip-hour: 20

Configuration options:

Best Practices

Troubleshooting

Next Steps