Automatically save and restore form input values using localStorage or sessionStorage.

Basic Usage

Add data-persist to any input to save its value:

The value is automatically:

  • Restored when the page loads
  • Saved on every input change

Storage Scope

By default, values are saved to localStorage (persists across sessions). Use data-persist-scope for session-only storage:

Form Draft Example

Save an entire form as a draft:

Form Reset: When a form is reset, html★ automatically clears the persisted values for all inputs in that form.

Supported Input Types

Input TypeWhat's Saved
text, email, tel, url, etc.value
textareavalue
checkboxchecked state
radioselected value
selectselected value

Storage Keys

Values are stored with a htmlstar: prefix to avoid conflicts:

JavaScript API

Clear persisted values programmatically:

Privacy Consideration: Don't persist sensitive data like passwords or personal information. Use session storage for sensitive drafts that should be cleared when the browser closes.