State
Persistence
State stays in memory by default. To persist it, explicitly choose session storage or local storage; Demetria versions and validates its saved snapshot.
Storage option
createForm({
target,
schema,
persistence: {
type: 'sessionStorage',
key: 'demetria:signup'
}
});
Supported types are sessionStorage and
localStorage. The versioned snapshot contains schema
identity, the current step, and form values. Invalid, incompatible, or
unavailable stored state is ignored and reported through
getState().persistenceStatus.
Demetria saves after value changes and successful step transitions, including completion. It does not expire or clear stored state automatically; an application can remove its known storage key when the flow is complete.
Real page-to-page flow
Use the same schema and persistence configuration on each document.
Set its initial step for the current document and navigate from
onStepChange. The
multi-page example
demonstrates this using window.location.assign, so Next
changes documents rather than swapping a form in place.
Security and privacy
Web Storage is readable by scripts on the same origin. Do not store passwords, payment information, government identifiers, health data, or other sensitive values there.
- Treat restored data as untrusted input.
- Use a namespaced key and remove it when the flow is complete.
-
Prefer
sessionStoragefor short-lived examples; choose storage based on your threat model. - Always validate and authorize submitted values on the server.