I am creating a lightning app in which I have different sidebar menus, which should take the user to different page inside the same app. I have done this by dividing the parent component in two part

1st which has the sidebar and emits the event when someone clicks any menu item 2nd which has the main body content which changes the component when any menu item is selected

the main issue with this approach is that this will not support any browser back functionality, and as the URL state is not changing. I also found navigateToURL which could help to change the url, and aura:locationChange which could help to capture changes. Suggest me if this approach is correct and what are the other solution for implementing navigation in the lightning app with supporting functionality browser back and getting query param.Thanks..

1 Answer 1


Yes, you should use force:navigateToURL to navigate forward, and aura:locationChange to detect changes in state going backwards and forwards. This is in the documentation:

Use relative URLs to navigate to different screens within your app.

  • Thanks for the reply, I tried implemented this but I can see that this is not working in the SPA fashion. Each time I change the url or just the # value the page is reloaded hence reloading all the init functions which, to be executed only once (As its gathering data for the whole application). do we have any way to stop reloading and only changing the component based on url hash value. Mar 30, 2018 at 10:33
  • If you are using SPA, you may like to show/hide components on click of your menu options. The best way to do in SPA fashion would be show the landing component on initialization and hide all other. Then based on the click, toggle the visibility of the components.
    – Jayant Das
    Apr 5, 2018 at 20:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .