@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/dialogs

No 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#

ImportKey exports
@solidnative-dev/dialogscreateAlertService, AlertService, AlertRequest, AlertButton, AlertResult, AlertPresentationInProgressError
@solidnative-dev/dialogs/react-nativecreateReactNativeAlertService, AlertPresentationInProgressError
@solidnative-dev/dialogs/solidcreateAlertController, 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 cancelable is enabled. iOS supports up to 32 buttons plus one cancel, destructive, and preferred button and appearance metadata.
  • Single-alert invariant: Only one native alert may be active at a time per process. Overlapping calls reject with AlertPresentationInProgressError instead 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.