Skip to content

@samline/forms

Bind forms, validate, watch fields, and submit with fetch — no framework required.

@samline/forms binds to an HTMLFormElement, keeps field state in sync with the DOM, runs validation, lets you react to changes via watchers or subscribers, and ships a serialized payload for fetch flows. It is the only runtime entrypoint since v2.0.0 — no framework wrapper, no virtual DOM, just one factory and a focused method surface.

  • Vanilla-first — Works with native HTML forms, embedded scripts, static sites, and server-rendered templates (Blade, ERB, Twig).
  • Two entrypoints — Import the ESM factory for bundlers, or drop a single <script> for the browser global (window.Forms).
  • Optional peer — Pairs with @samline/formatter for phone, card, numeral and date masks — installs only when you need it.
  • Chainable API — Most methods return the same FormController so setup reads fluently.
  • Reactivewatch, observe, and subscribe give you per-field and whole-form reactions without manual plumbing.
  • Zero runtime dependencies — Tiny footprint, ESM + CJS bundles, ships its own types.

API reference

Every public method, option, type and helper documented with signatures and runnable examples.

Browse the API →

Browser global

Use the pre-bundled window.Forms global when you don’t have a bundler — perfect for Shopify, WordPress, or classic templates.

window.Forms reference →

Recipes

End-to-end patterns: login, server errors, multi-step wizards, autosave, formatting, and SPA cleanup.

Browse examples →