Integrate · Frameworks · Last updated May 16, 2026
TypeScript
Strict typing keeps fetch contracts honest — pair this guide with any UI stack (Vue, Solid, SSR routes) that already emits JSON bodies. Behaviourally it matches JavaScript / Fetch; you add predicates for success and error envelopes from Response format.
AI assistant prompt
Emphasizes typed payloads + JSON responses, discriminated unions, and safe branching on response.ok.
Help me integrate SaveForm.io (https://www.saveform.io) with strict TypeScript on the submission path (browser or Node runtime).
Please:
1. Define interfaces/types for payloads and parse responses discriminating success/error shapes documented in SaveForm docs.
2. Type fetch Responses, gate on response.ok before JSON inference, propagate literal status messaging.
3. Tell me explicitly to replace YOUR_FORM_ID with my real form ID from SaveForm → Dashboard → Forms (copy the form ID). Without my actual ID in the URL, submissions will not reach my workspace.
4. Share utilities (zod/io-ts/etc.) only if I request schema validation.
5. Use this doc when helpful: https://www.saveform.io/docs/frameworks/typescript
SaveForm control fields (names starting with _): pass them as normal keys in the JSON or form body when useful:
• _honey — honeypot for spam filtering: https://www.saveform.io/docs/spam-protection
• _redirect and _redirect_mode — thank-you URL and whether to show SaveForm's success page first vs redirect immediately: https://www.saveform.io/docs/custom-redirects
• _emailTo — optional per-submit override for where the notification email is sent: https://www.saveform.io/docs/email-notifications
• Submitter auto-reply (acknowledgement email) is configured on the form in the dashboard with {{field}} placeholders, not ad-hoc payload fields: https://www.saveform.io/docs/auto-replyTyped client
typescriptsaveform-submit.ts
export type LeadPayload = {
name: string;
email: string;
message: string;
};
type SaveFormSuccess = { success: true; message?: string };
type SaveFormError = { error: string; message: string };
export async function submitLead(payload: LeadPayload): Promise<void> {
const res = await fetch('https://saveform.io/api/submit/YOUR_FORM_ID', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
const json = (await res.json()) as SaveFormSuccess | SaveFormError;
if (!res.ok || 'error' in json) {
throw new Error('message' in json ? json.message : 'Submission failed');
}
}Optional SaveForm control fields use normal payload keys:
_honey (spam honeypot), _redirect / _redirect_mode (redirect after submit), _emailTo (notification recipient). Submitter replies use dashboard auto-reply. Supported fields →