AbsoluteJS

@absolutejs/devices

@absolutejs/devicesv0.7.0betaNative Apps

Provider-neutral device capability contracts and web, SSR, and test adapters for AbsoluteJS

#Installation

BASH
bun add @absolutejs/devices

#Capabilities

Overview

Application-facing device capability contracts for AbsoluteJS. Runtime adapters are selected by AbsoluteJS; application code does not branch on its native provider.

The pre-1.0 core includes:

discriminated capability availability and normalized device errors;

Show 10 more

shared permission states without implicit permission requests;

platform, safe-area, reduced-motion, lifecycle, resume, restored-operation,

normalized link, network, and back contracts;

provider-neutral clipboard, system-share, safely degrading haptic, explicit

camera-permission, item-scoped photo-picker, and foreground location contracts;

portable keyboard visibility/height/dismissal and modern edge-to-edge system

bar appearance/visibility contracts;

bounded document selection, export, and preview without exposing native

filesystem paths;

explicit-permission local notification scheduling, cancellation, pending

Outcomes

What you can build

Build on the supported package contract

Use @absolutejs/devices through its supported public entry points.

Hardening checklist

Production guidance

Make every external boundary explicitPin the deployed @absolutejs/devices version, replace example or memory-backed dependencies with durable implementations, bound external calls, protect credentials, and emit enough evidence to retry or recover safely.

Follow in order

Troubleshooting path

1
Trace from the first failed boundary
Reproduce the smallest canonical @absolutejs/devices example, confirm the supported entry point and version in the API explorer, then inspect the first boundary that did not produce its documented result.

#@absolutejs/devices quick start

Partial snippet

# @absolutejs/devices

TS
import {
  camera,
  clipboard,
  documents,
  haptics,
  keyboard,
  location,
  localNotifications,
  photos,
  pushNotifications,
  share,
  systemBars,
} from "@absolutejs/devices";

await clipboard.writeText("Copied");
await share.share({ text: "Hello from AbsoluteJS" });
await haptics.impact("light");
const removeKeyboard = await keyboard.onChange(({ visible, heightPx }) => {
  document.documentElement.style.setProperty(
    "--absolute-keyboard-height",
    visible ? `${heightPx}px` : "0px",
  );
});
await systemBars.setAppearance("light", "status");
const [document] = await documents.pick({
  accept: ["application/pdf", ".csv"],
  limit: 1,
});
if (document) await upload(document.blob);
await documents.export({ content: "Portable report", name: "report.txt" });
const permission = await camera.requestPermission();
if (permission.state === "granted") {
  const capture = await camera.takePhoto({ direction: "rear" });
  image.src = capture.webPath;
}

// Call from an intentional user action. The returned value contains no token;
// AbsoluteJS registers the installation through its authenticated shell.
await pushNotifications.enable();
const removePushAction = await pushNotifications.onAction(
  ({ notification }) => {
    console.log(notification.data);
  },
);
const [chosen] = await photos.pick({ limit: 1 });

const notificationPermission = await localNotifications.requestPermission();
if (notificationPermission.state === "granted") {
  await localNotifications.schedule({
    body: "Your report is ready.",
    data: { route: "/reports/42" },
    id: 42,
    title: "AbsoluteJS",
  });
}

const locationPermission = await location.requestPermission({
  precision: "coarse",
});
if (locationPermission.state === "granted") {
  const current = await location.current();
  const stop = await location.watch((event) => {
    if (event.type === "position") console.log(event.position);
  });
  // Stop promptly when the owning view no longer needs location updates.
  await stop();
}

#Public entry points

Supported entry points declared by this package manifest.

Package entry point declared in package.json.

@absolutejs/devices@absolutejs/devices/runtime@absolutejs/devices/ssr@absolutejs/devices/testing@absolutejs/devices/web

#Package commands

Scripts declared by this package manifest.

bun run buildbun build src/index.ts --outdir dist --target=browser && bun build src/runtime.ts --outdir dist --target=browser && bun build src/ssr.ts --outdir dist --target=browser && bun build src/testing.ts --outdir dist --target=browser && bun build src/web.ts --outdir dist --target=browser && tsc --emitDeclarationOnly -p tsconfig.build.json
bun run typechecktsc --noEmit

#API reference

Search the declarations exported by the current package type files. Expand a symbol to inspect its source-backed signature.

80 symbols
DeviceRuntimetypePermalinkSource
TS
type DeviceRuntime = "web" | "ssr" | "capacitor" | "expo" | "test";
Exported from @absolutejs/devices