@solidnative-dev/dialogs
Validated, promise-based native alerts for Solid Native. Drives React Native's DialogManagerAndroid and AlertManager TurboModules directly without evaluating Alert.js.
Installation#
sh
pnpm add @solidnative-dev/dialogsNo extra native dependency is required—uses React Native's built-in alert TurboModules.
Usage#
ts
import { createReactNativeAlertService } from "@solidnative-dev/dialogs/react-native";
import { createAlertController } from "@solidnative-dev/dialogs/solid";
const alerts = createAlertController(createReactNativeAlertService());
const result = await alerts.show({
title: "Remove download?",
message: "The local file will be deleted.",
buttons: [
{ id: "cancel", text: "Cancel", style: "cancel" },
{ id: "remove", text: "Remove", style: "destructive", preferred: true },
],
});
if (result.action === "button" && result.buttonId === "remove") {
// Perform the removal.
}Entrypoints#
| Import | Key exports |
|---|---|
@solidnative-dev/dialogs | createAlertService, AlertService, AlertRequest, AlertButton, AlertResult, AlertPresentationInProgressError |
@solidnative-dev/dialogs/react-native | createReactNativeAlertService, AlertPresentationInProgressError |
@solidnative-dev/dialogs/solid | createAlertController, SolidAlertController, AlertOwnerDisposedError, AlertPresentationInProgressError |
Behavior & platform notes#
- Stable button IDs: Results return
{ action: "button", buttonId }or{ action: "dismissed" }rather than platform-dependent integer indices. - Platform button limits: Android supports up to 3 buttons and reports Back / outside-tap dismissal when
cancelableis enabled. iOS supports up to 32 buttons plus onecancel,destructive, andpreferredbutton and appearance metadata. - Single-alert invariant: Only one native alert may be active at a time per process. Overlapping calls reject with
AlertPresentationInProgressErrorinstead of silently replacing an Android dialog. - Owner disposal & privacy: Disposing the Solid owner rejects pending promises with
AlertOwnerDisposedError(native OS dialogs cannot be dismissed programmatically, so disposal prevents late delivery into retired state). Titles, messages, and button labels are never recorded in causal telemetry.