Download Latest Version v2.5.0 source code.zip (170.0 kB) Google Add to Preferred Sources
Home / v2.3.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2026-09-28 1.3 kB
v2.3.0 source code.tar.gz 2026-09-28 123.2 kB
v2.3.0 source code.zip 2026-09-28 143.0 kB
Totals: 3 Items   267.4 kB 0

Minor Changes

  • #418 cf664cb Thanks @matthewhudson! - Add React hooks, support server-side rendering, and let orientation callbacks unsubscribe.

  • React hooks. current-device/react exports useDevice(), which returns { type, os, orientation }, and useOrientation(). Both re-render the component when the orientation changes. They need React 18 or later, which is an optional peer dependency.

  • Server-side rendering. Importing current-device without a DOM, as Next.js, Remix and Astro do on the server, threw ReferenceError: window is not defined. The import now works: there every method returns false, and device.type, device.os and device.orientation are 'unknown'. The hooks return 'unknown' on the server and while the page hydrates.
  • Unsubscribe. device.onChangeOrientation(callback) now returns a function that removes the callback. It returned nothing before.
  • Fix: device.orientation already has the new value when the orientation callbacks are called. It had the previous value until they had all returned.
Source: README.md, updated 2026-09-28