browser-screen-details

Wraps the Window Management API (window.getScreenDetails()) as global atoms exposing the current screen, all connected screens, and the permission state.

Permission required
Screen details are empty until you call requestScreenDetails(), which prompts for the window-management permission. Requires a secure context.

Install

bun add @valdres/browser-screen-details

Live example

Loading demo…

Usage

<script>
import { watch } from "valdres-svelte"
import { currentScreenAtom } from "@valdres/browser-screen-details"

const current = watch(currentScreenAtom)
</script>

{current.value?.label}: {current.value?.width} × {current.value?.height}

Exports

ExportKindType
currentScreenAtomatom (read-only)ScreenDetail | null
screensAtomatom (read-only)ScreenDetail[]
screenPermissionAtomatom (read-only)ScreenPermissionState
requestScreenDetailsutil fn() => Promise<ScreenDetail[] | null>
ScreenDetailtype{ label, left, top, width, height, availLeft, availTop, availWidth, availHeight, colorDepth, pixelDepth, devicePixelRatio, orientationType, orientationAngle, isPrimary, isInternal }
ScreenPermissionStatetype"prompt" | "granted" | "denied" | "unsupported"

Cross-framework

All state is global atoms, so it works in every framework — only the read primitive differs. The atoms stay empty until requestScreenDetails() resolves; call it once from anywhere.