@usefy/usefy 0.0.14 โ†’ 0.0.16

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.
package/README.md CHANGED
@@ -47,7 +47,7 @@
47
47
  - **๐Ÿš€ Zero Dependencies** โ€” Pure React implementation with no external dependencies
48
48
  - **๐Ÿ“ฆ Tree Shakeable** โ€” Import only the hooks you need to optimize bundle size
49
49
  - **๐Ÿ”ท TypeScript First** โ€” Complete type safety with full autocomplete support
50
- - **โšก SSR Compatible** โ€” Works seamlessly with Next.js, Remix, and other SSR frameworks
50
+ - **โšก SSR Safe** โ€” Works with Next.js, Remix, and other SSR frameworks without crashing
51
51
  - **๐Ÿงช Well Tested** โ€” High test coverage ensures reliability and stability
52
52
  - **๐Ÿ“– Well Documented** โ€” Detailed documentation with practical examples
53
53
 
@@ -392,6 +392,23 @@ All packages are comprehensively tested using Vitest to ensure reliability and s
392
392
 
393
393
  ---
394
394
 
395
+ ## SSR Compatibility
396
+
397
+ All hooks are SSR-safe and will not throw errors on the server.
398
+
399
+ | Hook | SSR Behavior |
400
+ | -------------------------------------------- | ------------------------------------------------ |
401
+ | `useToggle`, `useCounter` | โœ… Fully compatible (pure React state) |
402
+ | `useDebounce`, `useThrottle` | โœ… Fully compatible (uses `setTimeout`) |
403
+ | `useDebounceCallback`, `useThrottleCallback` | โœ… Fully compatible |
404
+ | `useLocalStorage`, `useSessionStorage` | โœ… Safe โ€” returns `initialValue` on server |
405
+ | `useClickAnyWhere` | โœ… Safe โ€” event listener only attached on client |
406
+ | `useCopyToClipboard` | โœ… Safe โ€” copy function only works on client |
407
+
408
+ > **Note**: `useLocalStorage` and `useSessionStorage` include proper `typeof window` checks and will gracefully fall back to `initialValue` during server-side rendering.
409
+
410
+ ---
411
+
395
412
  ## Related Links
396
413
 
397
414
  - ๐Ÿ“ฆ [npm Organization](https://www.npmjs.com/org/usefy)
package/dist/index.d.mts CHANGED
@@ -8,3 +8,5 @@ export { UseThrottleOptions, useThrottle } from '@usefy/use-throttle';
8
8
  export { ThrottledFunction, UseThrottleCallbackOptions, useThrottleCallback } from '@usefy/use-throttle-callback';
9
9
  export { InitialValue, UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from '@usefy/use-local-storage';
10
10
  export { InitialValue as SessionStorageInitialValue, UseSessionStorageOptions, UseSessionStorageReturn, useSessionStorage } from '@usefy/use-session-storage';
11
+ export { ClickOutsideEvent, MouseEventType, OnClickOutsideHandler, RefTarget, TouchEventType, UseOnClickOutsideOptions, useOnClickOutside } from '@usefy/use-on-click-outside';
12
+ export { EventTargetType, UseEventListenerOptions, useEventListener } from '@usefy/use-event-listener';
package/dist/index.d.ts CHANGED
@@ -8,3 +8,5 @@ export { UseThrottleOptions, useThrottle } from '@usefy/use-throttle';
8
8
  export { ThrottledFunction, UseThrottleCallbackOptions, useThrottleCallback } from '@usefy/use-throttle-callback';
9
9
  export { InitialValue, UseLocalStorageOptions, UseLocalStorageReturn, useLocalStorage } from '@usefy/use-local-storage';
10
10
  export { InitialValue as SessionStorageInitialValue, UseSessionStorageOptions, UseSessionStorageReturn, useSessionStorage } from '@usefy/use-session-storage';
11
+ export { ClickOutsideEvent, MouseEventType, OnClickOutsideHandler, RefTarget, TouchEventType, UseOnClickOutsideOptions, useOnClickOutside } from '@usefy/use-on-click-outside';
12
+ export { EventTargetType, UseEventListenerOptions, useEventListener } from '@usefy/use-event-listener';
package/dist/index.js CHANGED
@@ -25,7 +25,9 @@ __export(index_exports, {
25
25
  useCounter: () => import_use_counter.useCounter,
26
26
  useDebounce: () => import_use_debounce.useDebounce,
27
27
  useDebounceCallback: () => import_use_debounce_callback.useDebounceCallback,
28
+ useEventListener: () => import_use_event_listener.useEventListener,
28
29
  useLocalStorage: () => import_use_local_storage.useLocalStorage,
30
+ useOnClickOutside: () => import_use_on_click_outside.useOnClickOutside,
29
31
  useSessionStorage: () => import_use_session_storage.useSessionStorage,
30
32
  useThrottle: () => import_use_throttle.useThrottle,
31
33
  useThrottleCallback: () => import_use_throttle_callback.useThrottleCallback,
@@ -42,6 +44,8 @@ var import_use_throttle = require("@usefy/use-throttle");
42
44
  var import_use_throttle_callback = require("@usefy/use-throttle-callback");
43
45
  var import_use_local_storage = require("@usefy/use-local-storage");
44
46
  var import_use_session_storage = require("@usefy/use-session-storage");
47
+ var import_use_on_click_outside = require("@usefy/use-on-click-outside");
48
+ var import_use_event_listener = require("@usefy/use-event-listener");
45
49
  // Annotate the CommonJS export names for ESM import in node:
46
50
  0 && (module.exports = {
47
51
  useClickAnyWhere,
@@ -49,7 +53,9 @@ var import_use_session_storage = require("@usefy/use-session-storage");
49
53
  useCounter,
50
54
  useDebounce,
51
55
  useDebounceCallback,
56
+ useEventListener,
52
57
  useLocalStorage,
58
+ useOnClickOutside,
53
59
  useSessionStorage,
54
60
  useThrottle,
55
61
  useThrottleCallback,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAIO;AAGP,mCAKO;AAGP,yBAA2B;AAG3B,wBAAgD;AAGhD,0BAAqD;AAGrD,mCAIO;AAGP,0BAAqD;AAGrD,mCAIO;AAGP,+BAKO;AAGP,iCAKO;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n\n// useOnClickOutside\nexport {\n useOnClickOutside,\n type UseOnClickOutsideOptions,\n type OnClickOutsideHandler,\n type ClickOutsideEvent,\n type RefTarget,\n type MouseEventType,\n type TouchEventType,\n} from \"@usefy/use-on-click-outside\";\n\n// useEventListener\nexport {\n useEventListener,\n type UseEventListenerOptions,\n type EventTargetType,\n} from \"@usefy/use-event-listener\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iCAIO;AAGP,mCAKO;AAGP,yBAA2B;AAG3B,wBAAgD;AAGhD,0BAAqD;AAGrD,mCAIO;AAGP,0BAAqD;AAGrD,mCAIO;AAGP,+BAKO;AAGP,iCAKO;AAGP,kCAQO;AAGP,gCAIO;","names":[]}
package/dist/index.mjs CHANGED
@@ -21,13 +21,21 @@ import {
21
21
  import {
22
22
  useSessionStorage
23
23
  } from "@usefy/use-session-storage";
24
+ import {
25
+ useOnClickOutside
26
+ } from "@usefy/use-on-click-outside";
27
+ import {
28
+ useEventListener
29
+ } from "@usefy/use-event-listener";
24
30
  export {
25
31
  useClickAnyWhere,
26
32
  useCopyToClipboard,
27
33
  useCounter,
28
34
  useDebounce,
29
35
  useDebounceCallback,
36
+ useEventListener,
30
37
  useLocalStorage,
38
+ useOnClickOutside,
31
39
  useSessionStorage,
32
40
  useThrottle,
33
41
  useThrottleCallback,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n"],"mappings":";AAGA;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP,SAAS,kBAAkB;AAG3B,SAAS,iBAAuC;AAGhD,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP;AAAA,EACE;AAAA,OAIK;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Re-export all hooks from individual packages\n\n// useClickAnyWhere\nexport {\n useClickAnyWhere,\n type UseClickAnyWhereOptions,\n type ClickAnyWhereHandler,\n} from \"@usefy/use-click-any-where\";\n\n// useCopyToClipboard\nexport {\n useCopyToClipboard,\n type UseCopyToClipboardOptions,\n type UseCopyToClipboardReturn,\n type CopyFn,\n} from \"@usefy/use-copy-to-clipboard\";\n\n// useCounter\nexport { useCounter } from \"@usefy/use-counter\";\n\n// useToggle\nexport { useToggle, type UseToggleReturn } from \"@usefy/use-toggle\";\n\n// useDebounce\nexport { useDebounce, type UseDebounceOptions } from \"@usefy/use-debounce\";\n\n// useDebounceCallback\nexport {\n useDebounceCallback,\n type UseDebounceCallbackOptions,\n type DebouncedFunction,\n} from \"@usefy/use-debounce-callback\";\n\n// useThrottle\nexport { useThrottle, type UseThrottleOptions } from \"@usefy/use-throttle\";\n\n// useThrottleCallback\nexport {\n useThrottleCallback,\n type UseThrottleCallbackOptions,\n type ThrottledFunction,\n} from \"@usefy/use-throttle-callback\";\n\n// useLocalStorage\nexport {\n useLocalStorage,\n type UseLocalStorageOptions,\n type UseLocalStorageReturn,\n type InitialValue,\n} from \"@usefy/use-local-storage\";\n\n// useSessionStorage\nexport {\n useSessionStorage,\n type UseSessionStorageOptions,\n type UseSessionStorageReturn,\n type InitialValue as SessionStorageInitialValue,\n} from \"@usefy/use-session-storage\";\n\n// useOnClickOutside\nexport {\n useOnClickOutside,\n type UseOnClickOutsideOptions,\n type OnClickOutsideHandler,\n type ClickOutsideEvent,\n type RefTarget,\n type MouseEventType,\n type TouchEventType,\n} from \"@usefy/use-on-click-outside\";\n\n// useEventListener\nexport {\n useEventListener,\n type UseEventListenerOptions,\n type EventTargetType,\n} from \"@usefy/use-event-listener\";\n"],"mappings":";AAGA;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP,SAAS,kBAAkB;AAG3B,SAAS,iBAAuC;AAGhD,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP,SAAS,mBAA4C;AAGrD;AAAA,EACE;AAAA,OAGK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP;AAAA,EACE;AAAA,OAIK;AAGP;AAAA,EACE;AAAA,OAOK;AAGP;AAAA,EACE;AAAA,OAGK;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usefy/usefy",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "A collection of useful React hooks",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -17,16 +17,18 @@
17
17
  ],
18
18
  "sideEffects": false,
19
19
  "dependencies": {
20
- "@usefy/use-click-any-where": "0.0.14",
21
- "@usefy/use-copy-to-clipboard": "0.0.14",
22
- "@usefy/use-toggle": "0.0.14",
23
- "@usefy/use-counter": "0.0.14",
24
- "@usefy/use-debounce": "0.0.14",
25
- "@usefy/use-debounce-callback": "0.0.14",
26
- "@usefy/use-throttle": "0.0.14",
27
- "@usefy/use-local-storage": "0.0.14",
28
- "@usefy/use-throttle-callback": "0.0.14",
29
- "@usefy/use-session-storage": "0.0.14"
20
+ "@usefy/use-click-any-where": "0.0.16",
21
+ "@usefy/use-copy-to-clipboard": "0.0.16",
22
+ "@usefy/use-counter": "0.0.16",
23
+ "@usefy/use-debounce": "0.0.16",
24
+ "@usefy/use-toggle": "0.0.16",
25
+ "@usefy/use-debounce-callback": "0.0.16",
26
+ "@usefy/use-throttle-callback": "0.0.16",
27
+ "@usefy/use-throttle": "0.0.16",
28
+ "@usefy/use-local-storage": "0.0.16",
29
+ "@usefy/use-session-storage": "0.0.16",
30
+ "@usefy/use-on-click-outside": "0.0.16",
31
+ "@usefy/use-event-listener": "0.0.16"
30
32
  },
31
33
  "peerDependencies": {
32
34
  "react": "^18.0.0 || ^19.0.0"