Install betteruse using your preferred package manager:
npm install betteruseRequirements
- React 18 or later
- React DOM 18 or later
TypeScript Support
betteruse is written in TypeScript and ships with complete type definitions. No additional @types packages are required.
import { useHold } from 'betteruse'
import type { UseHoldOptions, UseHoldReturn } from 'betteruse'
Usage
Import the hooks you need directly from betteruse:
import { useHold, useIdle, useMeasure, echo } from 'betteruse'
Each hook is tree-shakeable, so your bundle will only include the hooks you actually use.
All hooks are SSR-safe and will not cause hydration mismatches when used with Next.js or other SSR frameworks.
Next Steps
Now that you have betteruse installed, explore the individual hook documentation:
- echo - Screen reader announcements
- useHold - Long press with progress
- useExitIntent - Exit intent detection
- useIdle - Idle detection
- useSelection - Text selection tracking
- useMeasure - Element measurement