The core class TapticKit is exported from the root package taptickit. Use it anywhere you can run browser JavaScript (bundlers, inline modules, etc.).
import { TapticKit } from "taptickit";
const haptic = new TapticKit();
button.addEventListener("click", () => {
haptic.trigger("success");
});
From taptickit you can also import:
defaultPatterns — preset definitions (same keys as string presets in trigger)Vibration, HapticPattern, HapticPreset, HapticInput, TriggerOptions, TapticKitOptionsversion — package version stringCall destroy() when you no longer need the instance (for example when leaving a SPA view) to remove DOM nodes and release audio resources used in debug mode.
haptic.destroy();
Use the static flag before changing UI:
if (TapticKit.isSupported) {
// show haptic affordances
}
See TapticKit for the full method list.