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
, andLightningPrompt
in Lightning Web Component
LightningAlert and LightningConfirm use the async-await approach and LightningPrompt uses the .then() approach in this example.