Skip to content

@samline/forms

Validate, observe, serialize, and submit native forms without adopting a UI framework.

@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. Use the main entrypoint, the browser module, or the global IIFE without a framework wrapper or virtual DOM.

  • Vanilla-first — Works with native HTML forms, embedded scripts, static sites, and server-rendered templates (Blade, ERB, Twig).
  • Three distribution surfaces — Main ESM/CJS API, browser registry module, or a global IIFE for 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.
  • Reactive — watch, 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 →