I am trying to lightning navigation, I am using the code of official docs (https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation)


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
    <aura:attribute name="url" type="String"/>
    <aura:attribute name="pageReference" type="Object"/>
    <aura:handler name="init" value="{! this }" action="{! c.init }"/>
    <lightning:navigation aura:id="navService"/>
    <a href="{!v.url}">Link</a>


    init : function(cmp, event, helper) {
        var navService = cmp.find("navService");
        // Sets the route to /lightning/o/Account/home
        var pageReference = {
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'home'
        cmp.set("v.pageReference", pageReference);
        // Set the URL on the link or use the default if there's an error
        var defaultUrl = "#";
            .then($A.getCallback(function(url) {
                cmp.set("v.url", url ? url : defaultUrl);
            }), $A.getCallback(function(error) {
                cmp.set("v.url", defaultUrl);

Upon using this component I am getting the following error: [Cannot read property 'setParams' of undefined]?

  • Did you check the documentation? Are you using this component in Lightning Experience or Salesforce Mobile App? Other situations are not supported, so if you need this feature elsewhere, you'll need to find an alternative solution. – sfdcfox Apr 23 '19 at 10:15
  • I need to use this navigation functionality in Lightning Application. @sfdcfox – Pratyk Jain Apr 23 '19 at 10:18
  • @PratykJain Are you using this component in Lighting Application (.app)? – Jayant Das Apr 23 '19 at 12:47
  • It's working on when the component is put on page. However, I need it to work on Lighting Application (.app). Is it any way to make it work? @JayantDas – Pratyk Jain Apr 25 '19 at 4:14

Please follow the code in the below Repository that will help you


  • pelase do not post link only asnwers, make sure you include the specifics, otherwise it might get deleted – glls Apr 23 '19 at 12:28

Based on your comments:

It's working on when the component is put on page. However, I need it to work on Lighting Application (.app).

You cannot use this in Lightning Application (.app). The only supported experiences for lightning:navigation are Lightning Experience & Salesforce Mobile App. If you need to achieve a similar functionality in your Lightning Application (.app), you will need to explore other ways out here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.