Navigate to a Web Page

The navigation service supports different kinds of pages in Lightning. Each page reference type supports a different set of attributes and state properties.

Instead of using force:navigateToURL, we recommend navigating to web pages using the lightning:navigate component with the standard__webPage page type.

This code shows examples of navigating to a web page using the old force:navigateToURL event.

// Old way to navigate to a web page
$A.get("markup://force:navigateToURL").setParams({ 
    url: 'https://salesforce.com', 
}).fire();

Replace the previous code that uses force:navigateToURL with the following code. This example shows how to navigate to a web page using the standard__webPage page type. It assumes that you added <lightning:navigation aura:id="navigationService" /> in your component markup.

cmp.find("navigationService").navigate({ 
    type: "standard__webPage", 
    attributes: { 
        url: 'https://salesforce.com' 
    } 
});