Skip to main content

App info and capabilities

The Desktop object tells your code which platform it runs on and what the shell can do there, so you can show a feature only where it works.

React TSX
import {
Desktop,
capabilities,
isDesktopAvailable,
} from '@react-native-gpui/core/desktop';

Reading app info​

Desktop.getInfo() resolves with the platform, the CPU architecture and the capabilities:

TypeScript
const { platform, arch, capabilities } = await Desktop.getInfo();

platform() returns the host platform synchronously (macos, windows or linux), and null in an app that has no desktop shell. It is the same value as Platform.OS.

Capabilities​

capabilities() reads the capabilities synchronously and never touches the main thread. Without a desktop shell every capability is false.

CapabilityMeaning
nativeAppMenuThe application menu is the platform's own.
nativeContextMenuThe platform can show its own context menu.
trayTray icons are supported.
trayPopoverAnchoredA tray popover is anchored to the icon.
windowPositionWindows can be positioned from code.
alwaysOnTopA window can stay above others.
visibleOnAllWorkspacesA window can be shown on every Space or workspace. macOS only for now; elsewhere the option is ignored.
transparentTitlebarA window can draw under its title bar.
clientDecorationsA frameless window can still be resized, so you can draw your own caption buttons. Always true on macOS and Windows; on Linux it follows what the compositor granted.
menuBarInWindowThe menu bar is drawn in the window, so hiding it has an effect.
React TSX
if (capabilities().menuBarInWindow) {
return <HideMenuBarToggle />;
}

Detecting the shell​

isDesktopAvailable is true when the desktop shell is installed. Code shared with an Android or iOS app can check it before calling the desktop modules.

Errors​

The desktop modules reject with a DesktopError. Its code is one of:

CodeMeaning
unsupportedThe operating system, or this app, cannot perform the operation.
invalid_argumentAn argument was not valid.
not_foundThe window or item does not exist.
reloadedThe JavaScript bundle reloaded before the call finished.
failedThe operation failed for another reason. See the message.