@velnai/form-svelte
v0.1.1
Published
Drop a Velnai form into any Svelte app. Thin iframe wrapper with typed props + event dispatching.
Maintainers
Readme
@velnai/form-svelte
Drop a Velnai lead-capture form into any Svelte app.
npm install @velnai/form-svelteUsage
<script lang="ts">
import { VelnaiForm } from '@velnai/form-svelte'
function onSubmitted() {
alert('Thanks!')
}
</script>
<VelnaiForm
publicKey="frm_abc123"
prefill={{ email: '[email protected]', name: 'Alex' }}
on:submit={onSubmitted}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| publicKey | string | required | The form's public key. |
| prefill | Record<string, unknown> | — | Field values to pre-populate. |
| lang | string | — | Locale code (e.g. 'es'). |
| previewToken | string | — | Optional preview token for DRAFT forms. |
| formsBase | string | 'https://forms.velnai.com' | Override the forms host. |
| autoResize | boolean | true | Auto-resize iframe height to match content. |
| initialHeight | number | 600 | Initial iframe height (px). |
Events
| Event | Detail | When |
|---|---|---|
| view | — | The form has booted and is interactive. |
| submit | — | The visitor submitted successfully. |
| close | — | A modal-mode form requested to close. |
| redirect | { url, prevent } | The form wants to redirect. Call event.detail.prevent() to suppress default navigation. |
License
MIT
