Orientation Lock
You'll learn how to control which screen orientation your Progressive Web App supports—portrait, landscape, or any.
What Is Orientation Lock?
When users install your PWA, you can specify whether the app should display in portrait mode (vertical), landscape mode (horizontal), or adapt to any orientation. This setting lives in your Web App Manifest and helps create a more app-like experience by ensuring your interface displays in the orientation that makes the most sense for your content.
Think of it like designing a newspaper versus a widescreen movie: newspapers work best held vertically, while movies demand horizontal viewing. Your PWA can communicate this preference to the device.
The orientation Property
In your manifest file, use the orientation property:
{
"name": "My Game",
"short_name": "Game",
"start_url": "/",
"display": "standalone",
"orientation": "landscape"
}
Valid Values
"portrait"— Locks to vertical orientation"landscape"— Locks to horizontal orientation"portrait-primary"— Primary portrait (usually normal upright)"portrait-secondary"— Upside-down portrait"landscape-primary"— Primary landscape (usually device held horizontally right)"landscape-secondary"— Opposite landscape orientation"natural"— Device's natural orientation"any"— Default; allows all orientations
When to Use It
Games, video players, and dashboard apps often benefit from landscape lock. Reading apps and social feeds typically prefer portrait. Most general-purpose apps should use "any" to respect user preference.
Note: This is a hint, not enforcement—users can still override if their device allows it.
Key Takeaway: The orientation property in your manifest lets you suggest portrait, landscape, or any orientation, creating a more focused experience when appropriate.