This is the documentation for Superforms version 1. The latest version can be found at superforms.rocks!

Snapshots

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:

Usage

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

export const snapshot = { capture, restore };

The export has to be on a +page.svelte page to work, it cannot be in a component.

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.