@formsreach/js
v0.3.0
Published
FormsReach plain JavaScript SDK and CDN script
Downloads
94
Maintainers
Readme
@formsreach/js
Plain JavaScript / CDN SDK for FormsReach — form backend for static sites and vanilla JS apps.
For AI coding agents, see AGENTS.md (API surface, do/don't, backend contract).
Install
npm install @formsreach/js
# or: yarn add @formsreach/js / pnpm add @formsreach/jsCDN
<script src="https://unpkg.com/@formsreach/js/dist/formsreach.min.js"></script>
<script>
FormsReach.init({ apiKey: "fr_your_key" });
</script>
<form data-formsreach>
<input type="text" name="name" required />
<input type="email" name="email" required />
<textarea name="message" required></textarea>
<button type="submit">Submit</button>
</form>Forms with data-formsreach are intercepted after FormsReach.init. The SDK injects honeypot (_gotcha) and time-trap (_ts) automatically — no extra markup required.
Programmatic submit
For frameworks or custom UI:
import { submitForm } from "@formsreach/js";
const { id, redirectUrl } = await submitForm({
apiKey: "fr_your_key",
data: { name: "Ada", email: "[email protected]" },
});All requests go to https://app.formsreach.com/api/v1/submit. The endpoint is built into the SDK and is not configurable.
Events
After init, the SDK dispatches DOM events on document:
formsreach:success—detail: { id, redirectUrl }formsreach:error—detail: { status, code, title, detail?, requestId? }
Examples
- HTML / plain JS — runnable static example
- Monorepo overview: root README
Related packages
| Package | When to use |
| ------------------------------- | --------------------------------- |
| @formsreach/react | React / Next.js — useFormsReach |
| @formsreach/vue | Vue / Nuxt — useFormsReach |
Build
pnpm --filter @formsreach/js build
# dist/index.js, dist/index.d.ts, dist/formsreach.min.jsLicense
MIT
