Use the Submit JSON JS Client to wire up a contact us form submission notification using Svelte.
submitjson
with your favorite package manager.pnpm add submitjson # OR npm i OR yarn add
Next initialize the client and handle the contact us form submission in your Svelte component:
<script>
import SubmitJSON from 'submitjson'
const sj = new SubmitJSON({ apiKey: 'sjk_xxx', endpoint: 'xxx' })
let name = ''
let email = ''
let message = ''
async function submit() {
await sj.submit({ name, email, message })
}
</script>
<form on:submit|preventDefault={submit}>
<input type="text" bind:value={name}>
<input type="email" bind:value={email}>
<textarea bind:value={message}>
<button type="submit">
Submit
</button>
</form>
🚛✨💚 Nice job, you successfully integrated Submit JSON with Svelte.