Founding price: $35, then $79.99 after 23:59 UTC on 4 November, then $79.99
Get ProA useAutosave hook and a status indicator: debounced saves with a single request in flight, a queued follow-up for edits made while saving, retry on failure, and a polite Saving, Saved or Failed announcement.
Derived from this item’s props table, because it declares no controls of its own. Changes drive the preview live.
import { AutosaveIndicator, useAutosave } from "@/components/ui/form-autosave"const autosave = useAutosave({
value: draft, // any serialisable value
onSave: (value) => api.saveDraft(value),
delay: 800,
})
<AutosaveIndicator {...autosave} onRetry={autosave.retry} />Call autosave.flush() before navigating away or before a final submit, so the last edit is not left in the delay window.
| Export | Description |
|---|---|
useAutosave(options) | Returns { status, savedAt, error, flush, retry }. |
AutosaveIndicator | The status line: Unsaved changes, Saving..., Saved at 14:32, Could not save. Retry. |
| Option | Type | Default | Description |
|---|---|---|---|
value | T | - | Compared as JSON text. |
onSave | (value) => void | Promise<void> | - | Reject to enter error. |
delay | number | 800 | Milliseconds after the last change. |
enabled | boolean | true | Turn it off while the form is invalid. |
saveOnHide | boolean | true | Save when the tab goes to the background. |
role="status" (polite) for pending, saving and saved, and role="alert" (assertive) for a failure. It stays mounted so a change from empty to text is announced.The component ships with a Testing Library test (form-autosave.test.tsx) that covers: its main behaviour, the keyboard path and the error or empty states.