fn
useScreenOrientation
v0.0.15testeddemoReactive Screen Orientation API. Tracks the current orientation `type` and `angle`, and exposes helpers to lock/unlock the orientation. SSR-safe.
Examples
ts
const { isSupported, orientation, angle, lockOrientation, unlockOrientation } = useScreenOrientation();ts
// Lock to landscape (must run from a user gesture / fullscreen context)
const { lockOrientation } = useScreenOrientation();
await lockOrientation('landscape');Demo
Loading demo…
Signature
ts
export function useScreenOrientation(options: UseScreenOrientationOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
options? | UseScreenOrientationOptions | Options (custom `window`) |
Returns
UseScreenOrientationReturn`{ isSupported, orientation, angle, lockOrientation, unlockOrientation }`