1

I am building a multi-step webform for users to fill out for an application. This will be an unauthenticated public page.

I was hoping to get some guidance on which storage to us for caching data between steps.

I want the browsers navigation buttons to maintain functionality of going back and forth through the form.

Right now I have smaller components encapsulated in a parent component. When the user navigates between the pages I save the state to sessionstorage in the browser. I would like to get away from this.

Are there any services/apis provided by lightning components to handle this. Some things I have explored are.

  • Using session/local storage in the browser to save state between pages. (I opted out of this because I don't want to lose data if users have this blocked.)
  • Using history state. (Might still use this)
  • Cache.Session storage in apex. This seems like its only use is for authenticated users

Any direction would be greatly appreciated.

3
  • 2
    Have you considered using onhashchange? You could change the hash of a page based on the state, and it's forward/backward-button friendly.
    – sfdcfox
    Apr 4 '19 at 23:46
  • So basically hash all the form values in an object and reference them from the hashed value?
    – joshii
    Apr 5 '19 at 16:30
  • Apparently the page keeps its state this way, works perfectly, thanks!!
    – joshii
    Apr 5 '19 at 18:33
1

One option is to use lightning-navigation apis, you can store all of your information in the state object of the page object reference. State is stored in the history object of the browser, so going back and forth between pages would allow your data to persist. Your components can then pull from the current page reference on the page and grab the needed data from the state object.

https://developer.salesforce.com/docs/component-library/bundle/lightning:navigation/documentation

There are probably some good videos online explaining it.

1
  • Can you provide a link regarding the state object? How do I reach it? Are you talking about the state object that is part of the standard__objectPage navigation type?
    – Arthlete
    Sep 4 '19 at 18:01

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.