Web FeaturesPWA Demos
Device Orientation

Device Orientation PWA Demo

With the DeviceOrientation JavaScript event, you can detect the orientation and motion of a device in three-dimensional space to create advanced interactive experiences in your PWAs.

Device Orientation Logo

Demo

Install the app, open it from your homescreen, request access to the device's sensors below, then rotate your device to see the values below change.

Z axis:
X axis:
Y axis:
orientation: unknown

Use Cases

The DeviceOrientation event is commonly used for detecting and responding to device orientation, including portrait and landscape modes, compass headings, and tilt directions.

This data is particularly useful for creating PWAs that showcase augmented and/or virtual reality experiences. You can also leverage this JavaScript even in interactive games, navigation apps, or PWAs that make use of a device's camera.

API

window.DeviceOrientationEvent

Code

Links & Documentation

Your app here

Ready to generate your PWA?

Try our PWA toolkit free of charge and without limits for 14 days. No credit card required.

Generate PWA See plans