function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Júlio LimaJúlio Lima 

What is the difference between 'force:showtoast' and 'lightning:notificationsLibrary showToast'?

What is the difference between use 'force:showtoast' and 'lightning:notificationsLibrary' showToast method as strategy to displays toast messages?

In developer doc follows this recomendation: We recommend using lightning:notificationsLibrary for displaying messages in the app via notices and toasts. (https://developer.salesforce.com/docs/component-library/bundle/force:showToast/documentation)

I wish to understand why.
Eduard PaninEduard Panin
Hello Júlio Lima,

In general, there is no difference between the two variants but the library looks more readable in the js code and supports only from 41.0 version

Thanks,
Eduard
Vinod AgrawalVinod Agrawal
force:showToast is pre-cursor to lightning:notificationsLibrary. Former can only shows notifications as toast whereas the latter can shows notifications as Notices or Toast. I will be not surprised if force:showToast gets deprecated therefore if you are writing a new component I would suggest using lightning:notificationsLibrary