Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

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.

1// Old way to navigate to a web page
2$A.get("markup://force:navigateToURL").setParams({ 
3    url: 'https://salesforce.com', 
4}).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.

1cmp.find("navigationService").navigate({ 
2    type: "standard__webPage", 
3    attributes: { 
4        url: 'https://salesforce.com' 
5    } 
6});