{"_id":"@akbeniwal/react-native-hooks","_rev":"5-c21af579414fc1fd327001e3f1890f53","name":"@akbeniwal/react-native-hooks","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@akbeniwal/react-native-hooks","version":"1.0.0","keywords":["react-native","hooks","react-hooks","useappstate","usekeyboard","usenetworkstatus","usedebounce","usethrottle","usecountdown","react-native-hooks"],"author":{"name":"Abhishek Beniwal"},"license":"MIT","_id":"@akbeniwal/react-native-hooks@1.0.0","maintainers":[{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"}],"homepage":"https://github.com/AKBeniwal1700/react-native-hooks#readme","bugs":{"url":"https://github.com/AKBeniwal1700/react-native-hooks/issues"},"dist":{"shasum":"3103c3bde7a52058215d24e645ea2be1ef9cd4fb","tarball":"https://registry.npmjs.org/@akbeniwal/react-native-hooks/-/react-native-hooks-1.0.0.tgz","fileCount":70,"integrity":"sha512-Xi0h83n/eM2m2X2rLEJrh9Qb118P96HeG+nf0F/zBNehBvyTkza2WHNcD3VhLrxOMwmhOypBB1RLILVtTFmJfQ==","signatures":[{"sig":"MEYCIQCcE+K9n8wOcbTjgDuJurFP+RpjqJzQ/Bijm6w7yRmaFAIhAO+2iAlLkSeuYANZKl7gwzQ39A5zh8GQWXZRthfLbXGd","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":77851},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"},"repository":{"url":"git+https://github.com/AKBeniwal1700/react-native-hooks.git","type":"git"},"_npmVersion":"10.9.8","description":"A high-performance collection of React Native hooks optimized for performance, memory safety and developer experience.","directories":{},"_nodeVersion":"22.22.3","_hasShrinkwrap":false,"devDependencies":{"react":"^19.2.7","typescript":"^6.0.3","@types/react":"^19.2.16","react-native":"^0.85.3","@react-native-clipboard/clipboard":"^1.16.3"},"peerDependencies":{"react":">=18.0.0","react-native":">=0.72.0"},"optionalDependencies":{"@react-native-clipboard/clipboard":"^1.16.3"},"_npmOperationalInternal":{"tmp":"tmp/react-native-hooks_1.0.0_1780662292302_0.5207433540271902","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@akbeniwal/react-native-hooks","version":"1.0.1","keywords":["react-native","hooks","react-hooks","useappstate","usekeyboard","usenetworkstatus","usedebounce","usethrottle","usecountdown","react-native-hooks"],"author":{"name":"Abhishek Beniwal"},"license":"MIT","_id":"@akbeniwal/react-native-hooks@1.0.1","maintainers":[{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"}],"homepage":"https://github.com/AKBeniwal1700/react-native-hooks#readme","bugs":{"url":"https://github.com/AKBeniwal1700/react-native-hooks/issues"},"dist":{"shasum":"0f3af1cbc528ac70c553a1938d8ff49ba23d5efc","tarball":"https://registry.npmjs.org/@akbeniwal/react-native-hooks/-/react-native-hooks-1.0.1.tgz","fileCount":70,"integrity":"sha512-WT/SYOyk9QxSxZRxE+xzgp4KgV21ftqHYp7e5vc3waiN2xbyP1t9voi756qnUKqsZABD2/Nl8YkMBjg2qBNxuA==","signatures":[{"sig":"MEYCIQCC9AP/CayNigf92L/HbqMyNMrToMpDkHVQqS6e2oQuZQIhAM3DUI/CwxFtEyhluOeMARsIeuKWGibFVPMo6xCNK1SL","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":78060},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"},"repository":{"url":"git+https://github.com/AKBeniwal1700/react-native-hooks.git","type":"git"},"_npmVersion":"10.9.8","description":"A high-performance collection of React Native hooks optimized for performance, memory safety and developer experience.","directories":{},"_nodeVersion":"22.22.3","_hasShrinkwrap":false,"devDependencies":{"react":"^19.2.7","typescript":"^6.0.3","@types/react":"^19.2.16","react-native":"^0.85.3","@react-native-clipboard/clipboard":"^1.16.3"},"peerDependencies":{"react":">=18.0.0","react-native":">=0.72.0"},"optionalDependencies":{"@react-native-clipboard/clipboard":"^1.16.3"},"_npmOperationalInternal":{"tmp":"tmp/react-native-hooks_1.0.1_1780662619331_0.3915643784489937","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@akbeniwal/react-native-hooks","version":"1.0.2","keywords":["react-native","hooks","react-hooks","useappstate","usekeyboard","usenetworkstatus","usedebounce","usethrottle","usecountdown","react-native-hooks"],"author":{"name":"Abhishek Beniwal"},"license":"MIT","_id":"@akbeniwal/react-native-hooks@1.0.2","maintainers":[{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"}],"homepage":"https://github.com/AKBeniwal1700/react-native-hooks#readme","bugs":{"url":"https://github.com/AKBeniwal1700/react-native-hooks/issues"},"dist":{"shasum":"6ca75fd3730fa64e3025ad082c67b07bb23fd081","tarball":"https://registry.npmjs.org/@akbeniwal/react-native-hooks/-/react-native-hooks-1.0.2.tgz","fileCount":70,"integrity":"sha512-zZkv8uczNnZYwRXKeN1Y5iHJXJovFAR5o0hl5z/iIFJgT6Y6Uwch18UWUMZONnIZSmawwqc0zKL0ko7VZko9lA==","signatures":[{"sig":"MEYCIQCvsMPBc971JuyzpicJXK2II4VGiIk7CJjEg+2szNuliQIhAII1UmPRG5/V5eJgbkSxECJszkWOaIlOwrvHpNa2iJne","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":77910},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"},"repository":{"url":"git+https://github.com/AKBeniwal1700/react-native-hooks.git","type":"git"},"_npmVersion":"10.9.8","description":"A high-performance collection of React Native hooks optimized for performance, memory safety and developer experience.","directories":{},"_nodeVersion":"22.22.3","_hasShrinkwrap":false,"devDependencies":{"react":"^19.2.7","typescript":"^6.0.3","@types/react":"^19.2.16","react-native":"^0.85.3","@react-native-clipboard/clipboard":"^1.16.3"},"peerDependencies":{"react":">=18.0.0","react-native":">=0.72.0"},"optionalDependencies":{"@react-native-clipboard/clipboard":"^1.16.3"},"_npmOperationalInternal":{"tmp":"tmp/react-native-hooks_1.0.2_1780663003002_0.03735303404761536","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@akbeniwal/react-native-hooks","version":"1.0.3","keywords":["react-native","hooks","react-hooks","useappstate","usekeyboard","usenetworkstatus","usedebounce","usethrottle","usecountdown","react-native-hooks"],"author":{"name":"Abhishek Beniwal"},"license":"MIT","_id":"@akbeniwal/react-native-hooks@1.0.3","maintainers":[{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"}],"homepage":"https://github.com/AKBeniwal1700/react-native-hooks#readme","bugs":{"url":"https://github.com/AKBeniwal1700/react-native-hooks/issues"},"dist":{"shasum":"bfbc5eb4b4470c7c479ff2cafe6ab65985957aea","tarball":"https://registry.npmjs.org/@akbeniwal/react-native-hooks/-/react-native-hooks-1.0.3.tgz","fileCount":70,"integrity":"sha512-C9FfJMA3SBBTUgPoO5aKnK+QqvXhruLQ5RfOtsxDRpDCrQpV7WTyGSeDSJOj1ccxXpbJGDmcfmcFbS1S4MvyXg==","signatures":[{"sig":"MEUCIQClFEqMGiM2Y0PD5IqIZM8HyQrGRJxhjyAiZdYOsUllqwIgbtJIbniAZxXMIN/jMLrVsdSnormvBPPVulpRs54ZKf8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":79699},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","prepare":"npm run build"},"_npmUser":{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"},"repository":{"url":"git+https://github.com/AKBeniwal1700/react-native-hooks.git","type":"git"},"_npmVersion":"10.9.8","description":"A high-performance collection of React Native hooks optimized for performance, memory safety and developer experience.","directories":{},"_nodeVersion":"22.22.3","_hasShrinkwrap":false,"devDependencies":{"react":"^19.2.7","typescript":"^6.0.3","@types/react":"^19.2.16","react-native":"^0.85.3"},"peerDependencies":{"react":">=18.0.0","react-native":">=0.72.0"},"_npmOperationalInternal":{"tmp":"tmp/react-native-hooks_1.0.3_1780663274175_0.8890872050154475","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@akbeniwal/react-native-hooks","version":"1.0.4","description":"A high-performance collection of React Native hooks optimized for performance, memory safety and developer experience.","main":"dist/index.js","types":"dist/index.d.ts","keywords":["react-native","hooks","react-hooks","useappstate","usekeyboard","networkstatus","usedebounce","netinfo","usecountdown","react-native-hooks"],"author":{"name":"Abhishek Beniwal"},"license":"MIT","homepage":"https://github.com/AKBeniwal1700/react-native-hooks#readme","repository":{"type":"git","url":"git+https://github.com/AKBeniwal1700/react-native-hooks.git"},"bugs":{"url":"https://github.com/AKBeniwal1700/react-native-hooks/issues"},"scripts":{"build":"tsc","prepare":"npm run build"},"peerDependencies":{"react":">=18.0.0","react-native":">=0.72.0"},"devDependencies":{"@types/react":"^19.2.16","react":"^19.2.7","react-native":"^0.85.3","typescript":"^6.0.3"},"_id":"@akbeniwal/react-native-hooks@1.0.4","_nodeVersion":"22.22.3","_npmVersion":"10.9.8","dist":{"integrity":"sha512-9tOqCb9uKqeX3aAOf/0HzbtYJi15OVDpjJAwXEfaK2vMGLaSQYr/Z5H8mR9ufrfD++AgyG24+D/lLvbO6wKCig==","shasum":"feb2d612318fd9ec8050c4805e6a86987749f075","tarball":"https://registry.npmjs.org/@akbeniwal/react-native-hooks/-/react-native-hooks-1.0.4.tgz","fileCount":70,"unpackedSize":79692,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEJ2tKWPtBQpdY5rseR9up8/hXIVJXJAODWKOVS15ee7AiBZtA2m540gfD7sD1/38Ino+HvMjBXR7h6QlZgL/P5ufg=="}]},"_npmUser":{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"},"directories":{},"maintainers":[{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-hooks_1.0.4_1780663739184_0.4285722636577789"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-05T12:24:52.204Z","modified":"2026-06-05T12:48:59.468Z","1.0.0":"2026-06-05T12:24:52.444Z","1.0.1":"2026-06-05T12:30:19.483Z","1.0.2":"2026-06-05T12:36:43.143Z","1.0.3":"2026-06-05T12:41:14.321Z","1.0.4":"2026-06-05T12:48:59.362Z"},"bugs":{"url":"https://github.com/AKBeniwal1700/react-native-hooks/issues"},"author":{"name":"Abhishek Beniwal"},"license":"MIT","homepage":"https://github.com/AKBeniwal1700/react-native-hooks#readme","keywords":["react-native","hooks","react-hooks","useappstate","usekeyboard","networkstatus","usedebounce","netinfo","usecountdown","react-native-hooks"],"repository":{"type":"git","url":"git+https://github.com/AKBeniwal1700/react-native-hooks.git"},"description":"A high-performance collection of React Native hooks optimized for performance, memory safety and developer experience.","maintainers":[{"name":"akbeniwal","email":"abhishekbeniwal363@gmail.com"}],"readme":"# @akbeniwal/react-native-hooks ⚡\n\nA high-performance, lightweight, and type-safe collection of **16 custom React Native hooks** optimized for performance, memory-leak prevention, and smooth 60fps UX. \n\n---\n\n## Key Features 🌟\n\n*   **100% Dependency-Free & Lightweight**: No external peer dependencies like `@react-native-clipboard/clipboard` or `@react-native-community/netinfo` required.\n*   **Speed & Latency Testing**: Monitor internet connection status, round-trip ping latency, quality classification, and measure download speed in Mbps on-demand.\n*   **Android-Specific Back Button Hooks**: Custom hooks for back-press events and standard \"Double-Tap to Exit\" Toast notifications.\n*   **Optimized Performance**: Internal callbacks are isolated inside `useRef` to prevent system listeners (keyboard, dimensions, back-handlers, app-states) from registering and tearing down repeatedly.\n*   **TypeScript Ready**: Fully typed out-of-the-box with auto-generated declaration maps.\n*   **Cross-Platform**: Support for Android, iOS, and React Native Web.\n\n---\n\n## Installation 📦\n\n```bash\nnpm install @akbeniwal/react-native-hooks\n# or\nyarn add @akbeniwal/react-native-hooks\n```\n\n---\n\n## Table of Hooks 📚\n\n| Hook | Purpose | Platform |\n| :--- | :--- | :--- |\n| [`useAppState`](#useappstate) | Tracks active/inactive/background app focus states with callbacks. | iOS, Android, Web |\n| [`useBackHandler`](#usebackhandler) | Android physical/virtual hardware back button press. | Android |\n| [`useClipboard`](#useclipboard) | Reads & writes to the system clipboard with copied feedback callback. | iOS, Android, Web |\n| [`useCountdown`](#usecountdown) | Full-featured countdown timer with pause, reset, and tick callbacks. | iOS, Android, Web |\n| [`useDebounce`](#usedebounce) | Debounces state values with optional change triggers. | iOS, Android, Web |\n| [`useKeyboard`](#usekeyboard) | Tracks virtual keyboard display status and dynamic height. | iOS, Android |\n| [`useNetworkStatus`](#usenetworkstatus) | Monitors internet connection, latency, speed test in Mbps, and offline alerts. | iOS, Android, Web |\n| [`usePrevious`](#useprevious) | Accesses the value of a state/prop from the previous render. | iOS, Android, Web |\n| [`useThrottle`](#usethrottle) | Throttles state update changes. | iOS, Android, Web |\n| [`useToggle`](#usetoggle) | Simple state toggle with `onChange`, `onTrue`, and `onFalse` callbacks. | iOS, Android, Web |\n| [`useAfterInteractions`](#useafterinteractions) | Defers execution of tasks until layout transition animations finish. | iOS, Android |\n| [`useLayout`](#uselayout) | Measures dynamic sizing and screen positions of views. | iOS, Android, Web |\n| [`useDoubleTapToExit`](#usedoubletaptoexit) | Prompts and exits app only on double-pressing Android back button. | Android |\n| [`useDeviceOrientation`](#usedeviceorientation) | Tracks rotation and current orientation status (`PORTRAIT` / `LANDSCAPE`). | iOS, Android, Web |\n| [`useInterval`](#useinterval) | Declarative version of `setInterval` (prevents stale state closures). | iOS, Android, Web |\n| [`useTimeout`](#usetimeout) | Declarative version of `setTimeout` (cleans up automatically on unmount). | iOS, Android, Web |\n\n---\n\n## Quick Usage Reference 💡\n\n### useAppState\n```tsx\nimport { useAppState } from '@akbeniwal/react-native-hooks';\n\nconst appState = useAppState({\n  onForeground: () => console.log('App entered foreground!'),\n  onBackground: () => console.log('App entered background!'),\n});\n```\n\n### useBackHandler\n```tsx\nimport { useBackHandler } from '@akbeniwal/react-native-hooks';\n\nuseBackHandler(() => {\n  // Return true to prevent default back action\n  if (hasUnsavedChanges) {\n    showExitAlert();\n    return true; \n  }\n  return false;\n});\n```\n\n### useClipboard\n```tsx\nimport { useClipboard } from '@akbeniwal/react-native-hooks';\n\nconst [clipboardData, setString] = useClipboard({\n  onCopy: (text) => console.log(`Copied \"${text}\" to clipboard!`),\n});\n```\n\n### useCountdown\n```tsx\nimport { useCountdown } from '@akbeniwal/react-native-hooks';\n\nconst { seconds, isActive, start, pause, reset } = useCountdown({\n  initialSeconds: 60,\n  onExpire: () => alert('OTP expired!'),\n  onTick: (secs) => console.log(`${secs} seconds remaining`),\n});\n```\n\n### useDebounce\n```tsx\nimport { useDebounce } from '@akbeniwal/react-native-hooks';\n\nconst [searchQuery, setSearchQuery] = useState('');\nconst debouncedQuery = useDebounce(searchQuery, 500, (value) => {\n  fetchSearchResults(value);\n});\n```\n\n### useKeyboard\n```tsx\nimport { useKeyboard } from '@akbeniwal/react-native-hooks';\n\nconst { keyboardShown, keyboardHeight } = useKeyboard({\n  onShow: (height) => console.log(`Keyboard visible with height: ${height}`),\n  onHide: () => console.log('Keyboard hidden'),\n});\n```\n\n### useNetworkStatus\n```tsx\nimport { useNetworkStatus } from '@akbeniwal/react-native-hooks';\n\nconst { \n  isConnected, \n  isInternetReachable, \n  latencyMs, \n  connectionQuality, \n  internetSpeed, \n  isTestingSpeed, \n  runSpeedTest \n} = useNetworkStatus({\n  pingIntervalMs: 30000, // Ping Google every 30 seconds\n  onOnline: () => console.log('Back online! syncing database...'),\n  onOffline: () => console.log('Network connection lost!'),\n});\n```\n\n### usePrevious\n```tsx\nimport { usePrevious } from '@akbeniwal/react-native-hooks';\n\nconst [count, setCount] = useState(0);\nconst prevCount = usePrevious(count); // returns count from previous render\n```\n\n### useThrottle\n```tsx\nimport { useThrottle } from '@akbeniwal/react-native-hooks';\n\nconst throttledScrollY = useThrottle(scrollY, 100);\n```\n\n### useToggle\n```tsx\nimport { useToggle } from '@akbeniwal/react-native-hooks';\n\nconst [isModalOpen, toggleModal] = useToggle(false, {\n  onTrue: () => console.log('Modal Opened'),\n  onFalse: () => console.log('Modal Closed'),\n});\n```\n\n### useAfterInteractions\n```tsx\nimport { useAfterInteractions } from '@akbeniwal/react-native-hooks';\n\nconst interactionsFinished = useAfterInteractions(() => {\n  loadExpensiveChartData();\n});\n```\n\n### useLayout\n```tsx\nimport { useLayout } from '@akbeniwal/react-native-hooks';\nimport { View } from 'react-native';\n\nconst [layout, onLayout] = useLayout({\n  onChange: (metrics) => console.log('New layout:', metrics),\n});\n\nreturn <View onLayout={onLayout} />;\n```\n\n### useDoubleTapToExit\n```tsx\nimport { useDoubleTapToExit } from '@akbeniwal/react-native-hooks';\n\n// Setup on Android\nuseDoubleTapToExit('Press back button again to exit the app.');\n```\n\n### useDeviceOrientation\n```tsx\nimport { useDeviceOrientation } from '@akbeniwal/react-native-hooks';\n\nconst orientation = useDeviceOrientation((currentOrientation) => {\n  console.log('Orientation changed to:', currentOrientation);\n});\n```\n\n### useInterval\n```tsx\nimport { useInterval } from '@akbeniwal/react-native-hooks';\n\nuseInterval(() => {\n  // Increments or processes state safely without stale closures\n  tickCounter();\n}, isPaused ? null : 1000);\n```\n\n### useTimeout\n```tsx\nimport { useTimeout } from '@akbeniwal/react-native-hooks';\n\nuseTimeout(() => {\n  dismissBanner();\n}, 5000);\n```\n\n## Author 👤\n\n**Abhishek Beniwal**\n- GitHub: [@AKBeniwal1700](https://github.com/AKBeniwal1700)\n\n---\n\n## License 📄\n\nThis project is licensed under the MIT License.\n","readmeFilename":"README.md"}