Import createTaptic from taptickit/svelte. Unlike React/Vue hooks, this returns an object with an explicit destroy() — call it when the store or component is torn down if you create the instance yourself.
<script lang="ts">
import { createTaptic } from "taptickit/svelte";
const { trigger, cancel, destroy, isSupported } = createTaptic();
// In Svelte 5 / runes you might destroy in an $effect cleanup;
// in Svelte 4, use onDestroy(() => destroy()).
</script>
<button type="button" on:click={() => trigger("light")}>Light tap</button>
createTaptic(options?) passes TapticKitOptions to the constructor once. Use setDebug(boolean) on the returned object to toggle debug after creation.
| Property | Type | Description |
|---|---|---|
trigger | (input?, options?) => Promise<void> | TapticKit.trigger |
cancel | () => void | TapticKit.cancel |
destroy | () => void | TapticKit.destroy |
setDebug | (debug: boolean) => void | TapticKit.setDebug |
isSupported | boolean | TapticKit.isSupported |