Releases: siberiacancode/reactuse
Release list
v1.0.9
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 exposingregister,handleSubmit,trigger,watch,reset, and per-fielddirty,touched,errors, andsubmittingstate, with an optionalresolverfor schema validation through zod, yup, or valibot.useField— moved validation rules into the hook options sorequired,min,max,minLength,maxLength,pattern, andvalidatecan be declared once at the call site, withregisterparams overriding them per element.usePermission— added anonChangecallback, available as a second argument or through the options object, so consumers can react to permission changes without watchingstate.useNotification— added a hook that wraps the browser Notifications API, exposingsupported,notification,trigger,show, andclose.useNotification— the current notification is closed once the tab becomes visible again, since the user has already seen whatever it announced.
Fixes
useField— the registerrefno 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 throughvalueinstead ofdefaultValue, which selects have no DOM property for and which React overwrites on textareas during reconciliation.useField— thedirtystate and validation rules now readcheckedfor checkboxes and radios instead ofvalue, which always returned the stringonand made checkboxes permanently dirty while leavingrequiredunenforced.usePermission— thechangelistener is now attached to thePermissionStatusreturned bynavigator.permissions.query()rather than towindow, which the event never reaches, so external permission changes are finally reflected instate.usePermission— the listener is removed on unmount and whenever the permission name changes, instead of leaking for the lifetime of the page.usePermission—queryno longer throws whennavigator.permissionsis unavailable, returningpromptinstead.
v1.0.8
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 soretrynow accepts a function(failureCount, error) => booleanin addition to a boolean or number, letting you decide whether to retry based on the failure count or the error itself.useQuery— added theretryDelayoption to wait a given number of milliseconds before each retry, with the pending retry cancelled onabort(),refetch(), and unmount.useQuery— updatedrefetchIntervalto accept a function returning the next interval, orfalseto stop polling, enabling conditional polling that ends once a condition is met.useWebSocket— reworked the retry logic soretrynow accepts a function(failureCount, event) => booleanin addition to a boolean or number, giving full control over reconnection based on the failure count or the close event.useWebSocket— added theretryDelayoption to wait a given number of milliseconds before each reconnection attempt, with the pending retry cancelled onclose(),open(), and unmount.useWebSocket— added theheartbeatcallback and theheartbeatDelayoption, letting you send a keep-alive message on an interval while the connection is open, using whatever payload your protocol expects.useWebSocket— added theimmediatelyoption to control whether the connection opens on mount, allowing the socket to be opened manually throughopen()when set tofalse.usePermission— added theimmediatelyoption to control whether the permission is queried on mount, allowing the query to be triggered manually throughquery()when set tofalse.
Fixes
usePermission— thechangelistener is now attached to thePermissionStatusobject instead ofwindow, so state updates when the user grants or revokes the permission.
Changes
useWebSocket— renamed theonDisconnectedcallback toonCloseto align with the native WebSocket close event.useWebSocket— renamed thedisconnectedstatus toclosedto align with the native WebSocket close event.usePermission— replaced theenabledoption withimmediately, which only controls the query on mount rather than disabling the hook entirely.
v1.0.7
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 soretrynow accepts a function(failureCount, error) => booleanin addition to a boolean or number, letting you decide whether to retry based on the failure count or the error itself.useQuery— updatedrefetchIntervalto accept a function returning the next interval, orfalseto stop polling, enabling conditional polling that ends once a condition is met.useWebSocket— reworked the retry logic soretrynow accepts a function(failureCount, event) => booleanin addition to a boolean or number, giving full control over reconnection based on the failure count or the close event.useWebSocket— added theimmediatelyoption to control whether the connection opens on mount, allowing the socket to be opened manually throughopen()when set tofalse.useWebSocket— renamed theonDisconnectedcallback toonCloseto align with the native WebSocket close event.useDeviceList— added support for defaultconstraintsthrough options and per-call constraints throughtrigger(constraints), giving finer control over which permissions are requested when reading the device list.
v1.0.6
Fix device list hook
This release fixes the media device hook
Bugs
useDeviceList— fixed an unhandledNotReadableErrorintriggerwhen a camera or microphone was already in use by another application.
v1.0.5
Improve device list hook
This release improves the media device hook
Features
useDeviceList— improved thetriggerflow 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
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 fromnavigator.mediaDevices.enumerateDevices(). It now returns the full device list together with pre-groupedaudioInputs,audioOutputs, andvideoInputs, supports automatic initial loading, exposes manualupdateandtriggeractions, and listens to the nativedevicechangeevent 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 rawdevicesarray when full control is needed.useMediaStream— improved the hook for managing a livemediaDevices.getUserMedia()stream. It now supports both target-element and ref-based usage, exposesstart,stop,restart, andapplycontrols, tracksactiveandloadingstates, automatically attaches the stream to a media element, and providesonStart,onStop, andonErrorcallbacks.useDisplayMedia— improved the hook for working withnavigator.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 defaultconstraintsthrough options and per-call constraints throughstart(constraints), which makes screen and audio sharing scenarios more flexible.useDisplayMedia— addedonStartandonStopcallbacks 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, tracksactivestate, and correctly stops sharing when the underlying media tracks end.
v1.0.3
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
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 thetopandleftdirections. 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 theimmediatelyoption (defaultfalse) 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 thehasMoreoption (defaulttrue) that stops triggering the callback when set tofalse, so there's no need to guard against extra calls once all content is loaded.
v1.0.0
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
- new hook useCycleList
v0.3.47
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...