@smart-mailto/svelte
v0.2.0
Published
Svelte wrapper for smart-mailto — geo-aware webmail picker
Maintainers
Readme
@smart-mailto/svelte
Svelte action, component, and global init for smart-mailto — a geo-aware webmail picker that replaces broken mailto: links.
npm i @smart-mailto/svelteRequires svelte >= 4.0.0. Peer: @smart-mailto/core.
Usage
Svelte Action (on any anchor)
<script>
import { smartMailto } from '@smart-mailto/svelte';
</script>
<a href="mailto:[email protected]" use:smartMailto={{ theme: 'dark' }}>
Contact Us
</a>Component
<script>
import { SmartMailto } from '@smart-mailto/svelte';
</script>
<SmartMailto href="mailto:[email protected]" theme="dark">
Contact Us
</SmartMailto>Global Init (app-level — intercepts all mailto: links)
<!-- +layout.svelte (SvelteKit) -->
<script>
import { onMount, onDestroy } from 'svelte';
import { initGlobal } from '@smart-mailto/svelte';
let destroy;
onMount(() => { destroy = initGlobal({ theme: 'dark' }); });
onDestroy(() => destroy?.());
</script>
<slot />API
smartMailto (action)
| Param | Type | Default | Description |
| -------- | ------------------- | ------- | ------------------ |
| node | HTMLAnchorElement | — | The anchor element |
| config | SmartMailtoConfig | {} | Options |
initGlobal
| Param | Type | Default | Description |
| -------- | ------------------- | ------- | ---------------- |
| config | SmartMailtoConfig | {} | Options |
| returns | () => void | — | Cleanup function |
destroyGlobal
Cleans up the global interceptor. Alias for destroySmartMailto.
License
MIT
