A nice SvelteKit feature is snapshots, which save and restore data when the user navigates in the browser history. This is perfect for saving the form state, and with Superforms, you can take advantage of this in one line of code:


const { form, capture, restore } = superForm(data.form);

export const snapshot = { capture, restore };

Test it out

Modify the form below without submitting, then click the browser back button and then forward again. The form should be restored to its intermediate state. The taintedMessage option is also set to null, to avoid a dialog when navigating elsewhere.