What I need is a simple link to the org's home page. The documentation doesn't cover the case of aura:application but only cover the case of aura:component.

If I copy-paste the example inside an aura:application it throw an error:

navService.generateUrl is not a function.

Is it possible to use lightning:navigation or any other solution to use links inside aura:application? I prefer to avoid hardcoding urls.

  • 1
    if you look at the top right side experience section of documentation mentioned it supports only "Lightning Experience, Salesforce Mobile App" so in your case "Standalone Lightning App" it's not supported. – sdandamud1 May 28 '19 at 15:08

You cannot use lightning:navigation in an application.

If the Experience section of a Component's documentation does not list a particular experience, then that's not supported. In this case of lightning:navigation, the only supported experiences are:

  • Lightning Experience
  • Salesforce Mobile App

Your option here could be to use force:navigateToURL instead.

| improve this answer | |
  • Can I use force:navigateToURL without hardcoding the URL? I simply need to redirect the user to the home page. – gvgramazio May 28 '19 at 15:12
  • You don't necessarily need to hard code the URL, as long as you know the URL, you can have that as an attribute in your component, and utilize it in your JS. – Jayant Das May 28 '19 at 15:13
  • It's still hardcoding. I means that the application will not work in sandboxes but only in the production org since I have to save the url in an attribute. – gvgramazio May 28 '19 at 15:29
  • This topic is separate from the original ask of the question, but as a pointer there are ways to handle that how it can work in sandbox vs. production and that you don't need to necessarily hard code the URL in the attribute, you can always fetch it by making a server trip. – Jayant Das May 28 '19 at 15:31

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.