Skip to main content
Install ios-haptics and wire it up to a button click in four steps.
1

Install ios-haptics

2

Import haptic

3

Trigger a haptic on a button click

Pass haptic directly as an event listener, or call it inside your handler.
4

Try the different haptic types

ios-haptics exposes three feedback patterns based on context.

Complete example

A full TypeScript example with a button that cycles through all three haptic types.
Haptics only fire on physical iOS and Android devices. They are silently ignored on desktop browsers and simulators, so you can safely call them without any environment checks.

Next steps

API reference

Full documentation for haptic(), haptic.confirm(), haptic.error(), and supportsHaptics.

How it works

Learn about the Safari checkbox switch trick that powers ios-haptics under the hood.