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
Aakriti GoyalAakriti Goyal 

LWC Toast messages are not showing in the community

Hi All,

I am trying to create a custom LWC component to register users in the community. I want to display the error messages to the users for any invalid data. I am trying to use toast messages to show the errors but can not see any message on the community.

I tried to put that component on a record page & I can see the toast message there but not sure why the message is not displayed on the community page.
Below is the sample code that I am trying to execute in the community:-
import { LightningElement } from 'lwc';
import saveUser from '@salesforce/apex/CommRegister.createUser';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class CommRegister extends LightningElement {
       
       registerUser()
	{
		saveUser()
		.then((result) => {
			console.log(result);
		})
		.catch((error) => {
			console.log(error);
			const evt = new ShowToastEvent({
                        title: 'Error',
                        message: 'This is an error message',
                        variant: 'error',
                        mode: 'dismissable'
                    });
                    this.dispatchEvent(evt);
		});
  	}
}
Is there any limitation of the community or any setting that needs to be enabled before using toasts in custom LWC?

Thanks.
 
SwethaSwetha (Salesforce Developers) 
HI Aakriti  ,
A similar ask is posted here https://salesforce.stackexchange.com/questions/267571/showtoastevent-notification-is-not-displayed-in-lwc.

Hope this helps you. Please mark this answer as best if it does. Thank you
Aakriti GoyalAakriti Goyal
Thanks Swetha, but the documentation of the Platform Toast Event shows that it can be used in Experience builder sites. I am purely using LWC, not using lightning out.
 User-added image
ravi soniravi soni
hy Ankriti,
in my side it's working fine and I,m also receiving a toast message on community page.
Make sure that your error part is working.

you can confirm toast by using a custom button and check your toast is working fine and then check your error part.
don't forget to mark it as best answer.
Thank you
Aakriti GoyalAakriti Goyal
Thanks Veer,

I checked again, it's still not working for me on the register page. However, after adding the same component on the home page, it works as expected. I can see the toast message there. Not sure what is the issue when I put this component on the register page, it does not show any toast message. 

In the community, I have added the LWC component to the standard experience builder page for registration. Will it cause the issue?
I have updated the Register page mentioned in the below image only. 
User-added image

It's for the first time, I am setting it up. Many Thanks.
Abhishek Saxena 106Abhishek Saxena 106
Hi @aakriti.
Were yuou able to find any solution above mentioned as i am also facing the same issue.
Nikolay MitjulNikolay Mitjul
Greetings everyone,
is there any progress to that issue?

I have the same issue with toasts on my custom self registration LWC.

It would be nice to hear any other opinions/suggestions/workarounds.

Thank you in advance.
Nikolay MitjulNikolay Mitjul
Greetings everyone,

It is possible to create custom toast, to do that you have to create new LWC and connect it with your Custom registration component.

The solution is here - https://cafeforce.com/custom-toast-notification-lwc-salesforce/

If it helps, don't forget to mark it as best answer.
Thank you
Manav GautamManav Gautam

@nikolay
Thanks man!!

This is the excellent post regarding showing toast notification as you can use this component as a reusable component!!

Pon KumarPon Kumar
@Nikolay Mitjul  its not working in community pages .i want a lwc toast to work in community pages any body knows correct answer please reply