Forms

Receive form submissions on any site Lahyer hosts, without a backend.

Post a form to /.lahyer/forms/<name> on your own site. Lahyer keeps each submission on the project's Forms tab and emails it to the organization's owners; replying to the email answers the visitor.

There is nothing to set up: the path works on every site Lahyer hosts, on its .lahyer.app address and on custom domains. Apps made in Lahyer Studio have their forms wired this way for you.

With a plain HTML form

contact.html
<form action="/.lahyer/forms/contact" method="post">
  <label>Name <input name="name" required /></label>
  <label>Email <input name="email" type="email" required /></label>
  <label>Message <textarea name="message" required></textarea></label>

  <!-- Spam trap: people never see it, bots fill it in -->
  <input name="_gotcha" tabindex="-1" autocomplete="off" aria-hidden="true"
         style="position:absolute;left:-10000px" />

  <!-- Where to go after sending; without it, Lahyer shows a thank-you page -->
  <input type="hidden" name="_next" value="/thanks" />

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

With JavaScript

Send JSON and handle the answer yourself. Any 2xx answer means the submission arrived.

const response = await fetch("/.lahyer/forms/contact", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({ name, email, message, _gotcha: trap }),
});

if (response.ok) {
  showThanks();
} else {
  showError("Something went wrong, please try again.");
}

Fields

  • Name the fields anything you like. A field whose name contains email and holds an address becomes the reply-to of the email Lahyer sends.
  • Fields whose names start with _ are not stored. Two of them do something:
    • _gotcha is the spam trap. A submission that fills it in is kept as spam and never emailed.
    • _next is a path on your site to return to after a plain HTML form. Paths only: other sites are ignored.
  • The form name in the URL uses lowercase letters, digits, dashes and underscores, up to 40 characters: contact, newsletter, book-a-call.

Where submissions go

The project's Forms tab lists the submissions and lets you mark them read or unread, spam or not spam. Submissions sent from previews are marked as previews.

Each submission is emailed to the organization's owners as it arrives, with the visitor's address as the reply-to when the form has one.

Limits

LimitValue
Body64 KiB, as JSON or form fields (application/x-www-form-urlencoded)
FieldsUp to 50, names up to 100 characters, values up to 5,000
Per visitor5 submissions a minute
Per site30 submissions a minute and 500 a day (UTC)
Emails100 a day per site; later submissions are kept but not emailed

A submission over a limit is answered 429. File uploads (multipart/form-data) are not supported and are answered 415.

On this page