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
| Property | Type | Description |
|---|---|---|
impactOccurred | (style) => void | Trigger impact feedback |
notificationOccurred | (type) => void | Trigger notification feedback |
selectionChanged | () => void | Trigger selection change feedback |
callable | boolean | true if the host supports haptic methods |
Feedback Types
Impact Styles
Use impactOccurred(style) for general touch feedback.
| Style | Description |
|---|---|
'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.
| Type | Description |
|---|---|
'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
- Clipboard — system clipboard access
- Payments — accept payments
- Bridge Reference — full bridge API reference
Last updated on