| Name | Modified | Size | Downloads / 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
cf664cbThanks @matthewhudson! - Add React hooks, support server-side rendering, and let orientation callbacks unsubscribe. -
React hooks.
current-device/reactexportsuseDevice(), which returns{ type, os, orientation }, anduseOrientation(). 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 returnsfalse, anddevice.type,device.osanddevice.orientationare'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.orientationalready has the new value when the orientation callbacks are called. It had the previous value until they had all returned.