5

How can I redirect from one Lightning page to another lightning page through a click on a component link? I can only find answers for navigating from one lightning component to another lightning component.

sfdcfox
  • 489,769
  • 21
  • 458
  • 806
Tyler
  • 569
  • 1
  • 7
  • 25

2 Answers2

4

The force:navigateToURL event is used to navigate to a URL.

Use a relative url to stay in your current app and go to a different page.

goToNewPage: function(component, event, helper) {

    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url": "/newPage"
    });

    urlEvent.fire();
}

Use an absolute URL to open an external website in a new browser tab.

goToExternalSite: function(component, event, helper) {

    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url": "http:www.google.com"
    });

    urlEvent.fire();
}

Reference: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToURL.htm

Brett Nelson
  • 345
  • 1
  • 5
3

You don't go from page to page.. you load components in and out of the current application context.

component.set("v.body",newComponent);

here is a good discussion.. How to set up views and navigation in Lightning?

Benjamin Pirih
  • 2,384
  • 17
  • 28