@multiplatform.one/platform
v7.4.1
Published
Platform detection flags and utilities for multiplatform.one
Readme
@multiplatform.one/platform
Platform detection flags and small cross-platform utilities for multiplatform.one — one import to answer "where is this code running?" on web, native, desktop, and extension surfaces.
Install
pnpm add @multiplatform.one/platformWhat it owns
- Detection flags —
isWeb,isNative,isIos,isAndroid,isServer,isClient,isGnome,isTauri,isDesktop,isExpo,isNext,isStorybook,isChrome,isFirefox,isWebExtension,isChromeExtension,isFirefoxExtension,isIframe,isTouchable,isWebTouchable,isWindowDefined, … plus the fullplatformobject (platform.preciseName) - Env config — the
configreader used across packages - Utilities — cookies, clipboard,
downloadFile,openUrl, lifecycle helpers
What it must not do
- No UI, no theming, no data fetching — packages above it (
theme,core,logger, …) build on these flags, so this package stays dependency-light
Usage
import { isGnome, isNative, isServer, isTauri } from "@multiplatform.one/platform";
export function saveFile(contents: string) {
if (isServer) return;
if (isTauri) {
// webview desktop path (see @multiplatform.one/desktop)
return;
}
if (isGnome) {
// GTK desktop path (see @multiplatform.one/desktop)
return;
}
if (isNative) {
// share sheet / expo-file-system path
return;
}
// browser download path
}Flags are evaluated once at module load and are safe to use in render logic and module scope.
License
Apache-2.0
