Build on the supported package contract
Use @absolutejs/devices through its supported public entry points.
@absolutejs/devicesv0.7.1betaNative AppsProvider-neutral device capability contracts and web, SSR, and test adapters for AbsoluteJS
bun add @absolutejs/devicesApplication-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;
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
Use @absolutejs/devices through its supported public entry points.
Hardening checklist
Follow in order
# @absolutejs/devices
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();
}Supported entry points declared by this package manifest.
Package entry point declared in package.json.
Scripts declared by this package manifest.