npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@capawesome/capacitor-screen-orientation

v8.0.3

Published

Capacitor plugin to lock/unlock the screen orientation on Android, iOS, and Web.

Readme

Capacitor Screen Orientation Plugin

Capacitor plugin to lock/unlock the screen orientation.

Features

The Capacitor Screen Orientation plugin is one of the most complete orientation control solutions for Capacitor apps. Here are some of the key features:

  • 🖥️ Cross-platform: Supports Android, iOS, and Web.
  • 🔒 Orientation locking: Lock screen to specific orientations.
  • 🔓 Orientation unlocking: Unlock and restore automatic orientation.
  • 📱 Multiple orientations: Support for portrait, landscape, and specific orientations.
  • 🔄 Orientation detection: Get current screen orientation.
  • 📢 Event listeners: Listen to orientation change events.
  • 📐 Fine-grained control: Primary and secondary orientation modes.
  • 🍎 iPad support: Special configuration for iPad orientation locking.
  • 🤝 Compatibility: Works alongside the Home Indicator, Keep Awake and Navigation Bar plugins.
  • 🔁 Up-to-date: Always supports the latest Capacitor version.

Missing a feature? Just open an issue and we'll take a look!

Use Cases

The Screen Orientation plugin is typically used whenever certain screens of an app only work well in a specific orientation, for example:

  • Video players: Lock the screen to landscape for fullscreen video playback.
  • Games: Keep the game in a fixed orientation regardless of how the device is held.
  • Camera and scanner screens: Lock the screen to portrait while capturing photos or scanning codes.
  • Forms and reading views: Prevent accidental rotation while the user is typing or reading.
  • Responsive layouts: React to orientation changes with the screenOrientationChange event to adapt your UI.

Compatibility

| Plugin Version | Capacitor Version | Status | | -------------- | ----------------- | -------------- | | 8.x.x | >=8.x.x | Active support | | 7.x.x | 7.x.x | Deprecated | | 6.x.x | 6.x.x | Deprecated | | 5.x.x | 5.x.x | Deprecated |

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

 Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-screen-orientation` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capawesome/capacitor-screen-orientation
npx cap sync

iOS

General

On iOS you must add the following to your app's AppDelegate.swift:

+ import ScreenOrientationPlugin

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

+ func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
+   return ScreenOrientation.getSupportedInterfaceOrientations()
+ }

If your project still uses CocoaPods instead of Swift Package Manager (SPM), import CapawesomeCapacitorScreenOrientation rather than ScreenOrientationPlugin:

+ import CapawesomeCapacitorScreenOrientation

iPad Orientation Lock

On iPad, you must add the following to your app's Info.plist:

<key>UIRequiresFullScreen</key>
<true/>

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

The following examples show how to lock, unlock, and read the current screen orientation.

Lock the screen orientation

Lock the device to a specific orientation, for example landscape. Besides LANDSCAPE and PORTRAIT, you can also lock to a primary or secondary mode such as LANDSCAPE_PRIMARY for fine-grained control:

import { ScreenOrientation, OrientationType } from '@capawesome/capacitor-screen-orientation';

const lock = async () => {
  await ScreenOrientation.lock({ type: OrientationType.LANDSCAPE });
};

Unlock the screen orientation

Remove the orientation lock and restore automatic rotation:

import { ScreenOrientation } from '@capawesome/capacitor-screen-orientation';

const unlock = async () => {
  await ScreenOrientation.unlock();
};

Get the current screen orientation

Read the current orientation type of the device:

import { ScreenOrientation } from '@capawesome/capacitor-screen-orientation';

const getCurrentOrientation = async () => {
  const result = await ScreenOrientation.getCurrentOrientation();
  return result.type;
};

API

lock(...)

lock(options?: LockOptions | undefined) => Promise<void>

Locks the device orientation.

| Param | Type | | ------------- | --------------------------------------------------- | | options | LockOptions |


unlock()

unlock() => Promise<void>

Unlocks the device orientation.


getCurrentOrientation()

getCurrentOrientation() => Promise<GetCurrentOrientationResult>

Gets the current device orientation type.

Returns: Promise<GetCurrentOrientationResult>


addListener('screenOrientationChange', ...)

addListener(eventName: 'screenOrientationChange', listenerFunc: ScreenOrientationChangeListener) => Promise<PluginListenerHandle>

Listen for screen orientation changes.

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------------- | | eventName | 'screenOrientationChange' | | listenerFunc | ScreenOrientationChangeListener |

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.


Interfaces

LockOptions

| Prop | Type | Description | | ---------- | ----------------------------------------------------------- | -------------------------- | | type | OrientationType | The orientation lock type. |

GetCurrentOrientationResult

| Prop | Type | Description | | ---------- | ----------------------------------------------------------- | ----------------------------- | | type | OrientationType | The current orientation type. |

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

ScreenOrientationChange

| Prop | Type | Description | | ---------- | ----------------------------------------------------------- | ----------------------------- | | type | OrientationType | The current orientation type. |

Type Aliases

ScreenOrientationChangeListener

Callback to receive the screen orientation change notifications.

(change: ScreenOrientationChange): void

Enums

OrientationType

| Members | Value | Description | | ------------------------- | ---------------------------------- | ------------------------------------------------------------------- | | LANDSCAPE | 'landscape' | The orientation is either landscape-primary or landscape-secondary. | | LANDSCAPE_PRIMARY | 'landscape-primary' | The orientation is in the primary landscape mode. | | LANDSCAPE_SECONDARY | 'landscape-secondary' | The orientation is in the secondary landscape mode. | | PORTRAIT | 'portrait' | The orientation is either portrait-primary or portrait-secondary. | | PORTRAIT_PRIMARY | 'portrait-primary' | The orientation is in the primary portrait mode. | | PORTRAIT_SECONDARY | 'portrait-secondary' | The orientation is in the secondary portrait mode. |

FAQ

Why does the orientation lock not work on iPad?

For the orientation lock to work on iPad, you must add the UIRequiresFullScreen key with the value true to your app's Info.plist file, as described in the Installation section. Also make sure that you have applied the required changes to your AppDelegate.swift.

Do I need to modify my AppDelegate on iOS?

Yes. You must implement the supportedInterfaceOrientationsFor method in your app's AppDelegate.swift and return ScreenOrientation.getSupportedInterfaceOrientations(), as shown in the Installation section. Without this change, the orientation lock has no effect on iOS.

What is the difference between LANDSCAPE and LANDSCAPE_PRIMARY?

The LANDSCAPE type covers both landscape modes, so the device can be rotated between landscape-primary and landscape-secondary while locked. The LANDSCAPE_PRIMARY and LANDSCAPE_SECONDARY types lock the screen to exactly one of the two landscape modes. The same applies to PORTRAIT, PORTRAIT_PRIMARY and PORTRAIT_SECONDARY.

How do I restore automatic rotation after locking the orientation?

Simply call the unlock() method. It removes the orientation lock so that the device rotates automatically again based on the user's device settings.

How can I react to orientation changes?

Add a listener for the screenOrientationChange event using the addListener(...) method. The listener receives the new orientation type every time the screen orientation changes. Use removeAllListeners() to remove all listeners when you no longer need them.

Can I use this plugin with Ionic, React, Vue or Angular?

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

Related Plugins

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Changelog

See CHANGELOG.md.

License

See LICENSE.

Credits

This plugin is based on the Capacitor Screen Orientation plugin. Thanks to everyone who contributed to the project!