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
David Benkoel 3David Benkoel 3 

Page redirection best practice in a LWC

Hi,

I need to perform a simple redirect to a standard web page, from a LWC.

Is it a good practice to use the approach (and if yes why?) :
 
this[NavigationMixin.GenerateUrl]({
            type: 'standard__webPage',
            attributes: {
                url: redirectUri
            }
        })

Thank you
Shiraz HodaShiraz Hoda

Hi David,

Yes, This is the way to navigate to different pages in LWC. You will also need to import the NavigationMixin function from the lightning/navigation module in order to achieve this. For more information please find link to resource provided by salesforce. If this resolves your concern, Kindly mark it as best answer.

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_navigate

Regards,
Shiraz