Static sites

How to Add a Contact Form to a Static Website

Understand the difference between form markup and submission processing, then choose an integration that fits a static site.

By FormToInbox7 min readUpdated 2026-09-03

A static site can display and validate a form. It still needs a deliberate destination for the data: a hosted endpoint, your own server function, or a client-side handoff to an email or messaging app.

Choose the submission model first

The generated HTML is portable. Its action determines what happens next. Self-hosted code gives you control, a hosted endpoint can store and notify, and app handoffs prepare a draft without sending data through FormToInbox.

  1. Choose an HTTPS endpoint or an email, WhatsApp, SMS, Messenger or Telegram handoff.
  2. Review the destination’s privacy and retention behavior.
  3. Test the selected path on every device class you support.

Embed the generated files

Place the HTML in the page, load the scoped stylesheet, and load the generated script with defer. Keep the generated class prefix so host-site styles are less likely to conflict.

<link rel="stylesheet" href="/forms/contact-form.css">
<!-- paste the generated form markup here -->
<script src="/forms/contact-form.js" defer></script>

Do not put secrets in front-end code

Anything delivered to the browser is public. Never embed SMTP passwords or private API keys in JavaScript. Client handoff destinations such as an email address, phone number or username are also visible; use a server-side endpoint when the destination must stay private.

Verify the deployed path

After publishing, test the real URL. Check field validation, the success and error paths, keyboard use, mobile layout and the actual network destination.

Frequently asked questions

Will the form work on Astro, Eleventy or plain HTML?

Yes. The exported markup, CSS and JavaScript do not depend on a front-end framework.

Can a static site keep submissions?

Not by itself. Persistent storage requires a server-side or hosted processing layer.

Can I use the free builder without an account?

Yes. The FormToInbox free builder runs in the browser and stores its draft locally on that device.

Primary sources

Turn the guide into a working form

Start from a template, change the fields and take the code with you.

Open the free builder
Global privacy
Necessary storage

Keeps your form-builder draft and privacy choice on this device.

Always on
Sale or targeted-ad sharing

FormToInbox does not sell personal information or share it for cross-context behavioural advertising.

Off