Skip to Content
React SDKHaptic Feedback
View .md

Haptic Feedback

Trigger native tactile feedback through the host app’s haptic engine — button taps, success confirmations, selection changes, and more.

Quick Start

function LikeButton() { const { impactOccurred, callable } = useHaptic(); if (!callable) return null; return ( <button onClick={() => { impactOccurred('medium'); // ... your logic }}> Like </button> ); }

All haptic methods are fire-and-forget — they return nothing and never throw. Outside the Alien app they’re silent no-ops.

Return Values

PropertyTypeDescription
impactOccurred(style) => voidTrigger impact feedback
notificationOccurred(type) => voidTrigger notification feedback
selectionChanged() => voidTrigger selection change feedback
callablebooleantrue if the host supports haptic methods

Feedback Types

Impact Styles

Use impactOccurred(style) for general touch feedback.

StyleDescription
'light'Subtle tap — toggles, minor UI changes
'medium'Standard tap — button presses
'heavy'Strong tap — significant actions
'soft'Soft, muted tap
'rigid'Sharp, crisp tap

Notification Types

Use notificationOccurred(type) for outcome feedback.

TypeDescription
'success'Action completed successfully
'warning'Something needs attention
'error'Action failed

Selection

Use selectionChanged() for picker or scroll selection feedback.

function Picker({ items }) { const { selectionChanged } = useHaptic(); return ( <select onChange={() => selectionChanged()}> {items.map((item) => ( <option key={item.id}>{item.label}</option> ))} </select> ); }

Bridge API

For non-React apps, use the bridge directly. All haptic methods are fire-and-forget — no response event.

send('haptic:impact', { style: 'medium' }); send('haptic:notification', { type: 'success' }); send('haptic:selection', {});

Payloads

// haptic:impact { style: 'light' | 'medium' | 'heavy' | 'soft' | 'rigid'; } // haptic:notification { type: 'success' | 'warning' | 'error'; } // haptic:selection {}

Version Requirements

Haptic methods are available since contract version 0.2.4. To gate your UI on host support, read callable from the hook, or use useCallable:

const { callable } = useCallable('haptic:impact');

Next Steps

Last updated on