Registry / storage / form-storage

form-storage

JSON →
library1.3.5jsnpmunverified

A JavaScript library that stores form data to localStorage and re-applies it on page load, preventing users from having to re-enter form input. Version 1.3.5 is the current stable release. Development is minimal; no major updates in recent years. Differentiators: simplicity (no dependencies), support for ignore/include selectors, and automatic save/apply cycle.

npm install form-storage
INSTALL
IMPORT
SIG · FORM-STORAGE
F
form-storage
storagejavascriptv1.3.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FormStorage
✓ import FormStorage from 'form-storage'
✗ const FormStorage = require('form-storage')
Package is ESM only from version 1.0.0 onward; CommonJS require may fail or require a default import wrapper.
FormStorage (CDN global)
✓ const formStorage = new FormStorage(selector, options);
✗ const formStorage = new formStorage.FormStorage(selector, options);
CDN version exposes a global FormStorage constructor, not a namespace.
FormStorage (TypeScript)
✓ import FormStorage from 'form-storage'
✗ import { FormStorage } from 'form-storage'
Package does not ship TypeScript definitions; use @types/form-storage or declare module manually.

Shows how to create a FormStorage instance with include selectors, apply stored data, and save on form submit.

import FormStorage from 'form-storage'; const form = new FormStorage('#my-form', { name: 'my-form-data', includes: ['[name="email"]', '[name="message"]'] }); // Restore saved data on page load form.apply(); // Save form data on submit document.querySelector('#my-form').addEventListener('submit', () => form.save());
Debug
Known issues
gotchaThe 'name' option defaults to a fixed key in localStorage; if not specified, all forms with the same default name will share data.
fix
Always provide a unique 'name' per form to avoid data collisions.
affects: all
gotchaFormStorage only works with form elements; it does not support arbitrary containers or non-form inputs outside a <form>.
fix
Ensure the selector points to a valid HTML <form> element.
affects: all
deprecatedThe package has not been updated in over 5 years; no support for modern browser features like FormData or shadow DOM.
fix
Consider migrating to a maintained alternative like 'formdata-polyfill' or custom solution.
affects: <=1.3.5
Errors
Common errors & fixes
TypeError: formStorage.save is not a function
Package version < 1.0.0 used a different API (e.g., saveAll).
fix
Update to version 1.0.0 or later, or use the old API: formStorage.saveAll()
Uncaught ReferenceError: FormStorage is not defined
CDN script not loaded or loaded after use.
fix
Ensure <script src="https://unpkg.com/form-storage@1.2.0/build/form-storage.js"></script> is included before your code.
No such module 'form-storage'
Package not installed or module resolution failure.
fix
Run 'npm install form-storage' and ensure your bundler (webpack/browserify) is configured correctly.
Upgrade
Version history
1.3.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
form-storage — npm install form-storage · libregistry