Skip to main content
supportsHaptics is a boolean constant exported from ios-haptics. It is true on touch-pointer devices (coarse pointer) and false otherwise. Import

How it works

supportsHaptics uses window.matchMedia("(pointer: coarse)") to detect whether the primary pointer device is a touchscreen. In SSR and other non-browser environments where typeof window === "undefined", it returns false. The exact source logic:

Usage

haptic() checks supportsHaptics internally (after first checking navigator.vibrate), so calls on unsupported devices are silently no-ops. You only need to read supportsHaptics yourself if you want to conditionally show or hide UI based on haptic support.
You can also use it to conditionally render haptic-related UI:

Return value

boolean — true if the device has a coarse pointer (i.e., touchscreen), false otherwise.
supportsHaptics is evaluated once at module load time, not per-call. It will always be false during server-side rendering.