R
fn

useScreenOrientation

v0.0.15testeddemo

Reactive 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

ParameterTypeDescription
options?UseScreenOrientationOptionsOptions (custom `window`)

Returns

UseScreenOrientationReturn`{ isSupported, orientation, angle, lockOrientation, unlockOrientation }`