Install
npm i web-haptic-feedback
React
import { HapticButton, HapticOverlay } from "web-haptic-feedback/react";
<HapticButton feedback="success" onClick={save}>
Save
</HapticButton>
// Any element with position: relative
<div style={{ position: "relative" }}>
Card
<HapticOverlay label="Open card" onTap={open} />
</div>JavaScript
import { haptics } from "web-haptic-feedback";
await haptics.success();
await haptics.pattern([20, 40, 20]);
haptics.configure({ enabled: true });
await haptics.cancel();Results
requestedAccepted by the browser or native handler.unsupportedNo haptic capability available.requires-user-interactionNeeds a real tap first.blockedPrevented by a setting, policy or error.