Skip to main content

Form Persistance

One frustrating aspect of forms for users is when you are filling out a form and either your session expires, you accidentally close the browser or something else happens to your workflow and all of the data you have been entering is suddenly lost. React Formz has built-in localStorage persistance that will save a forms state locally and should something interupt a users ability to finish the form their values will be restored.

Forms can be persisted by using the saveDrafts prop. When using form persistance you must specify a unique form name that will be reused each time a user revists that specific form. So this name could be UserProfileForm form example and that will be the cache key.

If you want to display some feedback when a form is rehydrated using the cache you can pass a callback to the onFormRehydrated property. This callback will recieve the rehydrated state. You can use this to notify the user that you have restored their previous form values and that they can continue where they left off.