Skip to main content

generateHapticFeedback

Controls the device's vibration motor to deliver the specified haptic feedback type. Adds a tactile cue at important interaction moments — a button-tap confirmation, an error alert, a completion celebration.

Signature

import { generateHapticFeedback } from '@apps-in-toss/web-framework';

type HapticFeedbackType =
| 'tickWeak'
| 'tap'
| 'tickMedium'
| 'softMedium'
| 'basicWeak'
| 'basicMedium'
| 'success'
| 'error'
| 'wiggle'
| 'confetti';

declare function generateHapticFeedback(options: { type: HapticFeedbackType }): Promise<void>;

Parameters

NameTypeRequiredDescription
options.typeHapticFeedbackTypeFeedback intensity and character. See Feedback types below for a full comparison table.

Feedback types

The type parameter distinguishes feedback intensity and character.

TypeCategoryWhen to use
tickWeaktickLight list scroll, segment change
tickMediumtickMedium-strength tap, step transition
tapgeneralButton tap confirmation
softMediumsoftToggle, slider interaction
basicWeakbasicSubtle notification, hint
basicMediumbasicStandard selection, confirmation
successsemanticPayment complete, save success
errorsemanticError, failure
wiggleemphasisWarning, shake
confettiemphasisCelebration, reward grant

Returns

  • Promise<void> — resolves once the vibration request is delivered.
  • In the devtools mock, no actual vibration occurs — a log entry appears in the console instead. Real feedback is only felt inside the Toss app on iOS / Android.

Permission

No permission required — the haptic namespace is not bound to a PermissionName. For the typical permission flow used by other namespaces, see Guides — Permissions pattern.

Examples

Minimal

import { generateHapticFeedback } from '@apps-in-toss/web-framework';

await generateHapticFeedback({ type: 'success' });

Realistic — payment confirmation button

import { generateHapticFeedback } from '@apps-in-toss/web-framework';
import { useState } from 'react';

export function PayButton() {
const [status, setStatus] = useState<'idle' | 'pending' | 'done' | 'error'>('idle');

async function handlePay() {
setStatus('pending');
try {
// Your payment logic here.
await submitPayment();
await generateHapticFeedback({ type: 'success' });
setStatus('done');
} catch {
await generateHapticFeedback({ type: 'error' });
setStatus('error');
}
}

return (
<button type="button" onClick={handlePay} disabled={status === 'pending'}>
{status === 'pending' ? 'Processing…' : 'Pay now'}
</button>
);
}

Try it live

Open the Haptic page in sdk-example and run the generateHapticFeedback card.

Open in sdk-example

External references