0

I've created several different pages in a lightning Aura-type community. I want to implement the "Back" button functionality. Whenever a user navigates to a different page they should be able to navigate using the back button.(chaining of pages just like in breadcrumbs) We are publishing this community as an app on IOS using Mobile Publisher. The Standard Salesforce app uses the back button, I assume by some means they are able to extract the cache just like sessionstorage, localstorage of the browser, in a similar way I want to implement this in my custom lwc components. How can I do that or is there any other way to do so? One of the approaches is to create an lwc and pass the page-id as a URL parameter every time page is loaded, but this is quite cumbersome and not a very good approach.

1 Answer 1

0

You can definitely use local or session storage for this, to store a page reference whenever a link/button is clicked.

sessionStorage.setItem('pageReference', 'someReferenceID')

For our iOS/Android Mobile Publisher app we created a custom Message Channel specifically for this. The messaging service is pub-sub so we had our header LWC (present on all pages) subscribe to the channel and all child components publish to the channel. That way anytime a child component has a link clicked or initiates redirection to another page, it can send a message to the header to letting it know what the previous page was so the back button can have the appropriate link and go to the right page. The messaging service functionality is documented below.

https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.use_message_channel_intro

You must log in to answer this question.

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