+ );
+}
+```
+
+### Example 3: Custom Delay
+
+```tsx
+import { useDoubleClick } from '@/hooks/use-double-click';
+
+function MyComponent() {
+ const handlers = useDoubleClick({
+ onSingleClick: () => {
+ console.log('Single click');
+ },
+ onDoubleClick: () => {
+ console.log('Double click');
+ },
+ delay: 500, // 500ms window for double-click detection
+ });
+
+ return (
+
+ );
+}
+```
+
+## iOS-Specific Optimizations
+
+### 1. Touch Event Handling
+
+The hook uses native `touchend` events for better responsiveness on iOS:
+
+```typescript
+onTouchEnd: (event: TouchEvent) => {
+ event.preventDefault(); // Prevent ghost clicks
+ handleClick(event);
+}
+```
+
+### 2. Ghost Click Prevention
+
+iOS can fire both touch and click events for the same user interaction. The hook prevents this:
+
+```typescript
+if (event.type === 'click') {
+ const now = Date.now();
+ if (now - lastTouchTimeRef.current < 500) {
+ event.preventDefault();
+ return; // Ignore ghost click
+ }
+}
+```
+
+### 3. Timing Accuracy
+
+Uses `Date.now()` for precise timing measurements instead of relying on event timestamps:
+
+```typescript
+lastTouchTimeRef.current = Date.now();
+```
+
+## Testing
+
+Comprehensive tests are available in `tests/use-double-click.test.ts` covering:
+
+- ✅ Double-click detection
+- ✅ Single-click detection with delay
+- ✅ Double-click only mode
+- ✅ Custom delay timing
+- ✅ iOS touch events
+- ✅ Ghost click prevention
+- ✅ Multiple sequential double-clicks
+- ✅ Edge cases (3+ rapid clicks)
+
+Run tests with:
+
+```bash
+pnpm vitest --run tests/use-double-click.test.ts
+```
+
+## Demo
+
+A complete interactive demo is available at:
+- **Component**: `src/components/examples/DoubleClickDemo.tsx`
+- **Route**: Create a route that renders `` to see it in action
+
+The demo showcases:
+- Standard single + double click behavior
+- Double-click only mode
+- Click counters
+- Visual feedback
+- iOS-specific optimizations explanation
+
+## Browser Compatibility
+
+| Platform | Supported | Notes |
+|----------|-----------|-------|
+| iOS 12+ | ✅ | Fully tested with touch events |
+| iOS 18+ | ✅ | All features working |
+| Android | ✅ | Touch events supported |
+| Desktop | ✅ | Standard mouse events |
+| Safari | ✅ | Optimized for iOS Safari |
+| Chrome | ✅ | All platforms |
+| Firefox | ✅ | All platforms |
+
+## Technical Details
+
+### Type Safety
+
+The hook uses correct browser types:
+- `number` for `setTimeout` return value (not `NodeJS.Timeout`)
+- `window.setTimeout` explicitly used for browser environment
+- Proper TypeScript event types (`MouseEvent`, `TouchEvent`)
+
+### Memory Management
+
+- Clears timers properly to prevent memory leaks
+- Resets state after each interaction
+- No memory retained between hook re-renders
+
+### Performance
+
+- Minimal re-renders using `useCallback` and `useRef`
+- No state updates for internal timing logic
+- Efficient event handling
+
+## Migration from Native Events
+
+If you're currently using native double-click:
+
+```tsx
+// Before (unreliable on iOS)
+
+ Click me
+
+
+// After (reliable on all platforms)
+import { useDoubleClick } from '@/hooks/use-double-click';
+
+const handlers = useDoubleClick({
+ onDoubleClick: handleDoubleClick,
+});
+
+
+ Click me
+
+```
+
+## Troubleshooting
+
+### Issue: Single clicks are detected as double-clicks
+
+**Solution**: Increase the `delay` option:
+
+```tsx
+const handlers = useDoubleClick({
+ onDoubleClick: handleDoubleClick,
+ delay: 400, // Increase from default 300ms
+});
+```
+
+### Issue: Double-clicks are too slow
+
+**Solution**: Decrease the `delay` option:
+
+```tsx
+const handlers = useDoubleClick({
+ onDoubleClick: handleDoubleClick,
+ delay: 200, // Decrease from default 300ms
+});
+```
+
+### Issue: Touch events not working on desktop
+
+**Solution**: This is expected behavior. Desktop uses mouse events. The hook automatically handles both.
+
+## Contributing
+
+When modifying this hook:
+1. Ensure all tests pass: `pnpm vitest --run tests/use-double-click.test.ts`
+2. Test on actual iOS devices (iOS 12+)
+3. Verify no regressions on Android and Desktop
+4. Update documentation if API changes
+
+## License
+
+This hook is part of the project and follows the same license terms.
diff --git a/src/components/examples/DoubleClickDemo.tsx b/src/components/examples/DoubleClickDemo.tsx
new file mode 100644
index 0000000..d88710d
--- /dev/null
+++ b/src/components/examples/DoubleClickDemo.tsx
@@ -0,0 +1,136 @@
+import { useState } from 'react';
+import { useDoubleClick } from '../../hooks/use-double-click';
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';
+import { Badge } from '../ui/badge';
+
+export function DoubleClickDemo() {
+ const [singleClickCount, setSingleClickCount] = useState(0);
+ const [doubleClickCount, setDoubleClickCount] = useState(0);
+ const [lastAction, setLastAction] = useState('');
+ const [doubleOnlyCount, setDoubleOnlyCount] = useState(0);
+
+ // Example 1: Both single and double click
+ const handlers = useDoubleClick({
+ onSingleClick: () => {
+ setSingleClickCount(prev => prev + 1);
+ setLastAction('Single Click');
+ },
+ onDoubleClick: () => {
+ setDoubleClickCount(prev => prev + 1);
+ setLastAction('Double Click');
+ },
+ });
+
+ // Example 2: Double click only
+ const doubleOnlyHandlers = useDoubleClick({
+ onDoubleClick: () => {
+ setDoubleOnlyCount(prev => prev + 1);
+ },
+ doubleClickOnly: true,
+ });
+
+ return (
+
+
+
iOS Double-Click Demo
+
+ This demo showcases the iOS-optimized double-click detection hook.
+ Works reliably on iOS devices, preventing ghost clicks and handling touch events properly.
+
+
+
+
+ {/* Example 1: Standard Behavior */}
+
+
+ Standard Behavior
+
+ Single click after delay, or double-click immediately
+
+
+
+
+
+ Click or Tap Me!
+
+
+
+
+
+
{singleClickCount}
+
Single Clicks
+
+
+
{doubleClickCount}
+
Double Clicks
+
+
+
+ {lastAction && (
+
+ Last action:
+
+ {lastAction}
+
+
+ )}
+
+
+
+ {/* Example 2: Double-Click Only */}
+
+
+ Double-Click Only
+
+ Only responds to double-clicks, ignores single clicks
+
+
+
+