Navigate user from LWC to an external URL
Let's look at how can we navigate the user from LWC to an external URL.
Very rarely you might have to navigate the user from Lightning Web Components to an external URL. Out of the box, Salesforce provides a solution to that.
Let us look at a snippet on that.
The approach that we will be following is going to be as usual. We need to create a config object and pass it to the method this[NavigationMixin.Navigate]
.
In the config that we provide, we need to specify the type as standard__webpage
and in attributes, we need to specify the external URL, the rest of everything will be taken care by the platform.
Hope that was helpful!
I have put together a FREE course on Javascript that helps you master Lightning Web Components.
It just takes 2 hours to finish the course and you will be able to feel the difference.