Skip to content

Releases: siberiacancode/reactuse

v1.0.9

Choose a tag to compare

@debabin debabin released this 10 Jul 13:39

Add new hooks

This release introduces useForm, an orchestrator for managing multiple fields with schema validation support, and useNotification, a reactive wrapper around the browser Notifications API. It also fixes DOM initialization bugs in useField affecting selects, textareas, and checkboxes, and repairs usePermission, whose change listener was attached to a target the event never reaches.

Features

  • useForm — added a hook to manage a whole form, keeping values in the DOM and exposing register, handleSubmit, trigger, watch, reset, and per-field dirty, touched, errors, and submitting state, with an optional resolver for schema validation through zod, yup, or valibot.
  • useField — moved validation rules into the hook options so required, min, max, minLength, maxLength, pattern, and validate can be declared once at the call site, with register params overriding them per element.
  • usePermission — added an onChange callback, available as a second argument or through the options object, so consumers can react to permission changes without watching state.
  • useNotification — added a hook that wraps the browser Notifications API, exposing supported, notification, trigger, show, and close.
  • useNotification — the current notification is closed once the tab becomes visible again, since the user has already seen whatever it announced.

Fixes

  • useField — the register ref no longer reinitializes an element it has already seen, so a value chosen by the user survives rerenders instead of being reset to the initial value every time the callback ref is reattached.
  • useField — selects and textareas are now initialized through value instead of defaultValue, which selects have no DOM property for and which React overwrites on textareas during reconciliation.
  • useField — the dirty state and validation rules now read checked for checkboxes and radios instead of value, which always returned the string on and made checkboxes permanently dirty while leaving required unenforced.
  • usePermission — the change listener is now attached to the PermissionStatus returned by navigator.permissions.query() rather than to window, which the event never reaches, so external permission changes are finally reflected in state.
  • usePermission — the listener is removed on unmount and whenever the permission name changes, instead of leaking for the lifetime of the page.
  • usePermissionquery no longer throws when navigator.permissions is unavailable, returning prompt instead.

v1.0.8

Choose a tag to compare

@debabin debabin released this 09 Jul 07:22
0159eba

Improve async, connection, and permission hooks

This release reworks retry handling across async hooks, adds heartbeat and delay control to WebSocket connections, and fixes permission change tracking.

Features

  • useQuery — reworked the retry logic so retry now accepts a function (failureCount, error) => boolean in addition to a boolean or number, letting you decide whether to retry based on the failure count or the error itself.
  • useQuery — added the retryDelay option to wait a given number of milliseconds before each retry, with the pending retry cancelled on abort(), refetch(), and unmount.
  • useQuery — updated refetchInterval to accept a function returning the next interval, or false to stop polling, enabling conditional polling that ends once a condition is met.
  • useWebSocket — reworked the retry logic so retry now accepts a function (failureCount, event) => boolean in addition to a boolean or number, giving full control over reconnection based on the failure count or the close event.
  • useWebSocket — added the retryDelay option to wait a given number of milliseconds before each reconnection attempt, with the pending retry cancelled on close(), open(), and unmount.
  • useWebSocket — added the heartbeat callback and the heartbeatDelay option, letting you send a keep-alive message on an interval while the connection is open, using whatever payload your protocol expects.
  • useWebSocket — added the immediately option to control whether the connection opens on mount, allowing the socket to be opened manually through open() when set to false.
  • usePermission — added the immediately option to control whether the permission is queried on mount, allowing the query to be triggered manually through query() when set to false.

Fixes

  • usePermission — the change listener is now attached to the PermissionStatus object instead of window, so state updates when the user grants or revokes the permission.

Changes

  • useWebSocket — renamed the onDisconnected callback to onClose to align with the native WebSocket close event.
  • useWebSocket — renamed the disconnected status to closed to align with the native WebSocket close event.
  • usePermission — replaced the enabled option with immediately, which only controls the query on mount rather than disabling the hook entirely.

v1.0.7

Choose a tag to compare

@debabin debabin released this 06 Jul 09:23

Improve async and connection hooks

This release improves retry handling across async hooks, makes polling and reconnection more flexible, and adds constraint control to the device list hook.

Features

  • useQuery — reworked the retry logic so retry now accepts a function (failureCount, error) => boolean in addition to a boolean or number, letting you decide whether to retry based on the failure count or the error itself.
  • useQuery — updated refetchInterval to accept a function returning the next interval, or false to stop polling, enabling conditional polling that ends once a condition is met.
  • useWebSocket — reworked the retry logic so retry now accepts a function (failureCount, event) => boolean in addition to a boolean or number, giving full control over reconnection based on the failure count or the close event.
  • useWebSocket — added the immediately option to control whether the connection opens on mount, allowing the socket to be opened manually through open() when set to false.
  • useWebSocket — renamed the onDisconnected callback to onClose to align with the native WebSocket close event.
  • useDeviceList — added support for default constraints through options and per-call constraints through trigger(constraints), giving finer control over which permissions are requested when reading the device list.

v1.0.6

Choose a tag to compare

@debabin debabin released this 05 Jul 16:13

Fix device list hook

This release fixes the media device hook

Bugs

  • useDeviceList — fixed an unhandled NotReadableError in trigger when a camera or microphone was already in use by another application.

v1.0.5

Choose a tag to compare

@debabin debabin released this 05 Jul 15:35

Improve device list hook

This release improves the media device hook

Features

  • useDeviceList — improved the trigger flow for requesting media device permissions. It now provides a more reliable way to prompt access to cameras and microphones before refreshing the device list

v1.0.4

Choose a tag to compare

@debabin debabin released this 03 Jul 09:22

Improve screen sharing hook

This release improves the screen sharing API with a more flexible useDisplayMedia hook and a more convenient integration flow for media elements.

Features

  • useDeviceList — improved the hook for reading available media devices from navigator.mediaDevices.enumerateDevices(). It now returns the full device list together with pre-grouped audioInputs, audioOutputs, and videoInputs, supports automatic initial loading, exposes manual update and trigger actions, and listens to the native devicechange event to keep the list in sync.
  • useDeviceList — makes it easier to work with media device selection flows by separating microphones, speakers, and cameras out of the box, while still preserving access to the raw devices array when full control is needed.
  • useMediaStream — improved the hook for managing a live mediaDevices.getUserMedia() stream. It now supports both target-element and ref-based usage, exposes start, stop, restart, and apply controls, tracks active and loading states, automatically attaches the stream to a media element, and provides onStart, onStop, and onError callbacks.
  • useDisplayMedia — improved the hook for working with navigator.mediaDevices.getDisplayMedia(). It now supports both target-element and ref-based usage, making it easier to attach a shared screen stream directly to a video element.
  • useDisplayMedia — updated the API to support default constraints through options and per-call constraints through start(constraints), which makes screen and audio sharing scenarios more flexible.
  • useDisplayMedia — added onStart and onStop callbacks for reacting to sharing lifecycle events without extra effects.
  • useDisplayMedia — improved stream lifecycle handling so the hook automatically binds the stream to the media element, tracks active state, and correctly stops sharing when the underlying media tracks end.

v1.0.3

Choose a tag to compare

@debabin debabin released this 02 Jul 18:13

Add media device hooks

This release adds two new browser hooks for working with media devices and improves useGeolocation with a clearer control API and lifecycle callbacks.

Features

  • useDeviceList — added a new hook for reading available media devices from navigator.mediaDevices.enumerateDevices(). It returns the full device list along with pre-grouped audioInputs, audioOutputs, and videoInputs, supports automatic initial loading, exposes manual update and trigger actions, and listens to the native devicechange event to keep the list in sync.
  • useMediaStream — added a new hook for managing a live mediaDevices.getUserMedia() stream. It supports both target-element and ref-based usage, exposes start, stop, restart, and apply controls, tracks active and loading states, automatically attaches the stream to a media element, and provides onStart, onStop, and onError callbacks.
  • useGeolocation — improved the hook with a more explicit action-based API. It now exposes get for one-time reads, start and stop for watch control, and a watching flag for tracking the current watcher state.
  • useGeolocation — added support for immediately: false, allowing geolocation to be initialized lazily without starting a watcher on mount.
  • useGeolocation — added onChange and onError callbacks, making it easier to react to successful position updates and permission or retrieval errors without adding extra effects around the hook.
  • useGeolocation — improved state handling so loading, error, coordinates, altitude, heading, speed, and timestamp are updated consistently for both one-time reads and active watch mode.

v1.0.1

Choose a tag to compare

@debabin debabin released this 27 Jun 07:08

Improve hook

This release improves useInfiniteScroll with scroll compensation for reverse directions and new options for controlling auto-loading behavior.

Features

  • useInfiniteScroll — added scroll position compensation for the top and left directions. When content is prepended (e.g. loading older messages in a chat), the hook keeps the scroll position steady so the viewport no longer jumps.
  • useInfiniteScroll — added the immediately option (default false) that controls whether the hook keeps calling the callback while the content doesn't overflow the viewport. When disabled, the callback fires only on scroll, which is useful for chats or lists with a manual "load more" button where auto-filling isn't wanted.
  • useInfiniteScroll — added the hasMore option (default true) that stops triggering the callback when set to false, so there's no need to guard against extra calls once all content is loaded.

v1.0.0

Choose a tag to compare

@debabin debabin released this 26 Jun 07:08
f920410

First big release

We're excited to announce the first release! This initial version ships with a solid foundation of hooks, utility functions, an agent skill, and full documentation.

✨ What's included
Hooks — 164 ready-to-use hooks to streamline your workflow and handle common patterns out of the box.
Functions — 6 utility functions covering core operations.
Agent Skill — A built-in agent skill to extend functionality and automate tasks.
Documentation — Complete docs to get you started quickly, with usage examples and API reference.

Features

v0.3.47

Choose a tag to compare

@debabin debabin released this 22 Jun 12:24

Prepare for first release

createContext: Creates a typed context with additional utilities
createEventEmitter: Creates a type-safe event emitter
createReactiveContext: Creates a typed context selector with optimized updates for state selection
createStore: Creates a store with state management capabilities
makeDestructurable: Makes an object also iterable for array-style destructuring
useActiveElement: Hook for tracking the active element
useAsync: Hook that provides the state of an async callback
useAsyncEffect: Hook that triggers the effect callback on updates
useAudio: Hook that manages audio playback with sprite support
useAutoScroll: Hook that automatically scrolls a list element to the bottom
useBatchedCallback: Hook that batches calls and forwards them to a callback
useBattery: Hook for getting information about battery status
useBluetooth: Hook for getting information about bluetooth
useBoolean: Hook provides opportunity to manage boolean state
useBreakpoints: Hook that manages breakpoints
useBroadcastChannel: Hook that provides cross-tab/window communication
useBrowserLanguage: Hook that returns the current browser language
useBrowserLocation: Hook that returns reactive browser location state with navigation controls
useClickOutside: Hook to handle click events outside the specified target element(s)
useClipboard: Hook that manages a copy to clipboard
useConst: Hook that returns the constant value
useContextMenu: Hook that handles custom context menus on desktop and long press on touch devices
useControllableState: Hook that manages both controlled and uncontrolled state patterns
useCookie: Hook that manages cookie value
useCookies: Hook that manages cookie values
useCopy: Hook that manages copying text with status reset
useCounter: Hook that manages a counter
useCssVar: Hook that returns the value of a css variable
useDebounceCallback: Hook that creates a debounced callback
useDebounceEffect: Hook that runs an effect after a delay when dependencies change
useDebounceState: Hook that creates a debounced state
useDebounceValue: Hook that creates a debounced value
useDefault: Hook that returns the default value
useDeviceMotion: Hook that work with device motion
useDeviceOrientation: Hook that provides the current device orientation
useDevicePixelRatio: Hook that returns the device's pixel ratio
useDidUpdate: Hook that triggers the effect callback on updates
useDisclosure: Hook that allows you to open and close a modal
useDisplayMedia: Hook that provides screen sharing functionality
useDocumentEvent: Hook attaches an event listener to the document object for the specified event
useDocumentTitle: Hook that manages the document title and allows updating it
useDocumentVisibility: Hook that provides the current visibility state of the document
useDoubleClick: Hook that defines the logic when double clicking an element
useDropZone: Hook that provides drop zone functionality
useEvent: Hook that creates an event and returns a stable reference of it
useEventListener: Hook that attaches an event listener to the specified target
useEventSource: Hook that provides a reactive wrapper for event source
useEyeDropper: Hook that gives you access to the eye dropper
useFavicon: Hook that manages the favicon
useField: Hook to manage a form field
useFileDialog: Hook to handle file input
useFileSystemAccess: Hook for reading and writing local files via the File System Access API
useFocus: Hook that allows you to focus on a specific element
useFocusTrap: Hook that traps focus within a given element
useFps: Hook that measures frames per second
useFul: Hook that can be so useful
useFullscreen: Hook to handle fullscreen events
useGamepad: Hook for getting information about gamepad
useGeolocation: Hook that returns the current geolocation
useHash: Hook that manages the hash value
useHotkeys: Hook that listens for hotkeys
useHover: Hook that defines the logic when hovering an element
useIdle: Hook that defines the logic when the user is idle
useImage: Hook that load an image in the browser
useInfiniteScroll: Hook that defines the logic for infinite scroll
useIntersectionObserver: Hook that gives you intersection observer state
useInterval: Hook that makes and interval and returns controlling functions
useIsFirstRender: Hook that returns true if the component is first render
useIsomorphicLayoutEffect: Hook conditionally selects either useLayoutEffect or useEffect based on the environment
useKeyboard: Hook that helps to listen for keyboard events
useKeyPress: Hook that listens for key press events
useKeysPressed: Hook that tracks all currently pressed keyboard keys and their codes
useLastChanged: Hook for records the timestamp of the last change
useLatest: Hook that returns the stable reference of the value
useLess: Hook that can be so useless
useList: Hook that provides state and helper methods to manage a list of items
useLocalStorage: Hook that manages local storage value
useLockCallback: Hook that prevents a callback from being executed multiple times simultaneously
useLockScroll: Hook that locks scroll on an element or document body
useLogger: Hook for debugging lifecycle
useLongPress: Hook that defines the logic when long pressing an element
useMap: Hook that manages a map structure
useMask: Hook to apply an input mask
useMeasure: Hook to measure the size and position of an element
[us...

Read more