Registry / storage / spa-storage

spa-storage

JSON →
library2.0.2jsnpmunverified

Browser storage plugin for Svelte and Pinia that simplifies integration with localStorage and IndexedDB via localforage. Version 2.0.2 is current, with no recent release cadence indicated. Key differentiators include configurable encryption, key expiration with timeout, chain expiry, and dedicated functions for Svelte stores and Pinia stores. Supports ESM imports but lacks TypeScript definitions.

npm install spa-storage
INSTALL
IMPORT
SIG · SPA-STORAGE
S
spa-storage
storagejavascriptv2.0.2
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.

spaStorage
import { spaStorage } from 'spa-storage'
const spaStorage = require('spa-storage')
ESM only; no CommonJS support.
svelteFunctions
import { svelteFunctions } from 'spa-storage'
Used for Svelte store integration methods.
piniaFunctions
import { piniaFunctions } from 'spa-storage'
import { piniafunctions } from 'spa-storage'
Case-sensitive; incorrect casing fails to import.

Initializes localforage for IndexedDB storage, sets up a Svelte writable store with custom storage key, and demonstrates saving/loading store data to/from browser storage.

import { spaStorage, svelteFunctions, piniaFunctions } from 'spa-storage'; // Configure IndexedDB via localforage spaStorage.startForage(undefined, { name: 'SS_MY_CUSTOM_NAME', storeName: 'SS_CUSTOM_STORE_NAME' }); // Example: Svelte store usage import { writable } from 'svelte/store'; const store = writable({ themeDark: false }); const STORAGE_KEY = 'SS_APP_STORE'; async function setThemeDark(themeDark) { svelteFunctions.updateStoreKey(store, { themeDark }); await svelteFunctions.setSvelteStoreInStorage(store, STORAGE_KEY); } function getThemeDark() { return svelteFunctions.getStoreKey(store, 'themeDark'); } // Load store from storage on app init async function loadStores() { await svelteFunctions.getSvelteStoreInStorage(store, STORAGE_KEY); return true; }
Debug
Known issues
gotchaMissing TypeScript definitions: package ships without type declarations. Use `// @ts-ignore` or create a .d.ts file manually.
fix
Add `declare module 'spa-storage'` in a global .d.ts file.
affects: <=2.0.2
deprecated`spaStorage.startForage()` without callback: In version 2.0.2, calling `startForage` without a callback parameter logs a deprecation warning.
fix
Pass a callback function as first argument or await initialization.
affects: 2.0.2
breakingEncryption key not set: Methods like `setEncryptedKey` will throw if no encryption key is configured via `setEncryptionKey()`.
fix
Call `spaStorage.setEncryptionKey('your-key')` before using encrypted operations.
affects: >=1.0.0
gotcha`setSvelteStoreInStorage` overwrites the entire stored data per key; does not merge.
fix
Manually merge existing data before saving if partial update needed.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'setItem')
localforage not initialized before using spa-storage methods that rely on IndexedDB.
fix
Ensure `spaStorage.startForage()` is called early in application bootstrap before any storage operation.
Module not found: Can't resolve 'localforage'
localforage is not installed but is required when using `startForage`.
fix
Run `npm install localforage` and verify it is in node_modules.
Uncaught TypeError: svelteFunctions.updateStoreKey is not a function
Incorrect import: possibly imported as `sveltefunctions` (lowercase) or default import.
fix
Use named import: `import { svelteFunctions } from 'spa-storage'`.
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
localforageoptionalRequired for IndexedDB storage backend when using spaStorage.startForage()
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
spa-storage — npm install spa-storage · libregistry