react-visibility-hooks 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +25 -0
  2. package/package.json +12 -3
package/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
  [![Bundle Size](https://img.shields.io/bundlephobia/minzip/react-visibility-hooks)](https://bundlephobia.com/package/react-visibility-hooks)
8
8
  [![CI](https://github.com/exewhyz/react-visibility-hooks/actions/workflows/ci.yml/badge.svg)](https://github.com/exewhyz/react-visibility-hooks/actions/workflows/ci.yml)
9
+ [![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/exewhyz/react-visibility-hooks/badge)](https://scorecard.dev/viewer/?uri=github.com/exewhyz/react-visibility-hooks)
10
+ [![Docs](https://img.shields.io/badge/docs-visibility--hooks.grettech.com-blue)](https://visibility-hooks.grettech.com)
9
11
 
10
12
  A collection of lightweight React hooks that help you build performance-conscious, resource-aware applications. Detect page visibility, user idle state, network conditions, battery status, and more — with zero dependencies.
11
13
 
@@ -49,6 +51,21 @@ import {
49
51
  } from 'react-visibility-hooks';
50
52
  ```
51
53
 
54
+ ## When to use which hook
55
+
56
+ - **Start with `useDocVisible`** when you only need to pause/resume work based on tab visibility.
57
+ - **Use `useSmartPolling`** for visibility-aware polling with deduped updates.
58
+ - **Use `useNetworkAwarePolling`** when polling should adapt to offline/slow connections.
59
+ - **Use `useInactivityTimeout`** for session expiry and warning countdown UX.
60
+ - **Use `useWakeLock`** to keep screens awake during meetings, media, or kiosk flows.
61
+ - **Use `useBatteryAware`** to reduce work on low battery and improve perceived performance.
62
+
63
+ ## More examples
64
+
65
+ - [Combining hooks for adaptive behavior](https://visibility-hooks.grettech.com/advanced/combining-hooks/)
66
+ - [SSR behavior and defaults](https://visibility-hooks.grettech.com/advanced/ssr/)
67
+ - [Hook-by-hook API guides](https://visibility-hooks.grettech.com/)
68
+
52
69
  ## Hooks
53
70
 
54
71
  ### `useDocVisible`
@@ -514,6 +531,13 @@ function Feed() {
514
531
  }
515
532
  ```
516
533
 
534
+ ## Feedback and requests
535
+
536
+ - Need a new hook? Open a feature request: [New Feature](https://github.com/exewhyz/react-visibility-hooks/issues/new?labels=enhancement)
537
+ - Found a bug? Report it here: [Bug Report](https://github.com/exewhyz/react-visibility-hooks/issues/new?labels=bug)
538
+ - Want to improve docs/examples? Open a docs issue: [Docs Improvement](https://github.com/exewhyz/react-visibility-hooks/issues/new?labels=documentation)
539
+ - Before opening any issue or PR, please read [CONTRIBUTING.md](CONTRIBUTING.md).
540
+
517
541
  ## Contributing
518
542
 
519
543
  Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) before submitting a Pull Request.
@@ -524,6 +548,7 @@ MIT © [Aniket Raj](https://github.com/exewhyz)
524
548
 
525
549
  ## Links
526
550
 
551
+ - [📖 Documentation](https://visibility-hooks.grettech.com)
527
552
  - [GitHub Repository](https://github.com/exewhyz/react-visibility-hooks)
528
553
  - [Issue Tracker](https://github.com/exewhyz/react-visibility-hooks/issues)
529
554
  - [NPM Package](https://www.npmjs.com/package/react-visibility-hooks)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-visibility-hooks",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Tiny, SSR-safe React hooks for page visibility, idle detection, smart polling, network awareness, wake lock, battery status and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -28,7 +28,10 @@
28
28
  "prepare": "npm run build",
29
29
  "typecheck": "tsc --noEmit",
30
30
  "prepublishOnly": "npm run lint && npm run format && npm run typecheck && npm run test && npm run build",
31
- "size": "size-limit"
31
+ "size": "size-limit",
32
+ "bench": "npx tsx benchmarks/rerenders.bench.ts",
33
+ "docs:dev": "cd docs && npm run dev",
34
+ "docs:build": "cd docs && npm run build"
32
35
  },
33
36
  "keywords": [
34
37
  "react",
@@ -57,7 +60,13 @@
57
60
  "session-timeout",
58
61
  "focus-effect",
59
62
  "online-offline",
60
- "inactivity"
63
+ "inactivity",
64
+ "visibility-hooks",
65
+ "resource-aware",
66
+ "offline-first",
67
+ "react-polling",
68
+ "page-lifecycle",
69
+ "foreground-background"
61
70
  ],
62
71
  "author": "Aniket Raj",
63
72
  "license": "MIT",