Skip to content

v1.0.3

Choose a tag to compare

@debabin debabin released this 02 Jul 18:13
· 100 commits to main since this release

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.