Skip to main content
The Alert API launches an alert dialog with a specified title and message. It works on both iOS and Android, allowing you to show static alerts or prompt users for input (iOS only).

Import

Methods

alert()

Displays a native alert dialog with optional buttons.
string
required
The dialog’s title. Pass null or empty string for no title.
string
An optional message that appears below the title.
AlertButton[]
An optional array of buttons. If not provided, a default “OK” button is shown.
  • iOS: Supports any number of buttons
  • Android: Maximum of 3 buttons (neutral, negative, positive)
AlertOptions
Optional configuration object.Properties:
  • cancelable (boolean, Android only): Whether the alert can be dismissed by tapping outside
  • onDismiss (function, Android only): Callback when alert is dismissed
  • userInterfaceStyle (string): Can be ‘light’, ‘dark’, or ‘unspecified’

AlertButton Type

prompt() (iOS only)

Displays a native prompt dialog with a text input field.
string
required
The dialog’s title.
string
An optional message that appears below the title.
function | AlertButton[]
Either a callback function that receives the input text, or an array of buttons.
AlertType
The type of input field. Options:
  • 'default': Standard text input
  • 'plain-text': Plain text input
  • 'secure-text': Secure text entry (password)
  • 'login-password': Username and password fields
Default: 'plain-text'
string
The default text in the input field.
string
The keyboard type for the input field (e.g., ‘numeric’, ‘email-address’).
AlertOptions
Same options as alert() method.

Examples

Basic Alert

Alert with Buttons

iOS Prompt

Prompt with Login Fields

Android Cancelable Alert

Platform Differences

The prompt() method is iOS only. On Android, calling prompt() will have no effect.

Button Handling

iOS:
  • Supports unlimited number of buttons
  • Buttons can have style property: 'default', 'cancel', or 'destructive'
  • The isPreferred property highlights a specific button
Android:
  • Maximum of 3 buttons
  • Button order matters: [neutral, negative, positive]
  • The last button in the array is displayed as the positive action

Button Positioning

Best Practices

Always provide a cancel option for destructive actions to prevent accidental data loss.
On Android, alerts are dismissed when the app goes to the background. Consider this when implementing critical user flows.