DropForm with Svelte

Integrate DropForm into a Svelte app using fetch. Includes basic form submit, loading state, inline errors, and file uploads.

This guide shows how to submit forms to DropForm from Svelte using the Submission API endpoint: POST https://api.dropform.app/s/{uid}.

You’ll learn:

  • how to submit with fetch + FormData
  • how to show loading + success/error messages
  • how to upload files (multipart)
  • how to force multipart JSON mode (optional)

What you need

  • Your form endpoint: https://api.dropform.app/s/{uid}
  • A Svelte app (SvelteKit or Svelte SPA)

Svelte example (fetch + FormData)

The recommended approach is using FormData. It works for both text fields and file uploads, and you should not set the Content-Type header manually.

Example component

JSON mode (optional)

If your form doesn’t upload files and you want a pure JSON request, send application/json.

Example: submit JSON

File uploads

File uploads are automatic with FormData. If you want to guarantee a JSON response for multipart uploads, include a data part with Content-Type: application/json.

Example: force multipart JSON mode (optional)

Common gotchas

  • Do not set Content-Type for FormData: the browser sets the multipart boundary.
  • Prefer FormData for file uploads: JSON cannot include raw files.
  • Handle 400 errors: DropForm returns JSON describing validation errors in JSON mode.

Next steps