Salesforce Notifications with New Alert, Confirm, and Prompt Modules

--

From Summer22 we can use the new modules LightningAlert, LightningConfirm, and LightningPrompt instead of native APIs (window.alert(), window.confirm(), and window.prompt()) to create notifications from your Lightning web components.

Unlike the window.*() APIs, these modules' .open() functions don't halt execution on the page, and they each return a promise. Use async/await or .then() for any code that you want to execute after the modal closes.

How to use LightningAlert, LightningConfirm, and LightningPrompt in Lightning Web Component

myApp.html
MyApp.js

LightningAlert and LightningConfirm use the async-await approach and LightningPrompt uses the .then() approach in this example.

Demo

Reference: https://help.salesforce.com/s/articleView?id=release-notes.rn_lc_alert_confirm_prompt.htm&type=5&release=238

--

--

Abhilash Ananthakrishnan
Abhilash Ananthakrishnan

No responses yet