Registry / storage / metal-storage

metal-storage

JSON →
library2.0.1jsnpmunverified

Provides a convenient API for data persistence using a selected data storage mechanism. Current stable version is 2.0.1. Release cadence is unknown; last release appears older. It is part of the Metal.js ecosystem. Unlike larger storage libraries, it offers a lightweight abstraction over localStorage, sessionStorage, and other backends. Supports Node.js >=0.12 and npm >=3.

npm install metal-storage
INSTALL
IMPORT
SIG · METAL-STORAGE
M
metal-storage
storagejavascriptv2.0.1
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.

storage
import storage from 'metal-storage'
const storage = require('metal-storage')
ESM default import is the modern way.
getItem
import { getItem } from 'metal-storage'
import getItem from 'metal-storage/getItem'
Named export, not a separate module.
setItem
import { setItem } from 'metal-storage'
const { setItem } = require('metal-storage')
CommonJS require with destructuring also works.
removeItem
import { removeItem } from 'metal-storage'
Named export.
clear
import { clear } from 'metal-storage'
Named export.

Shows basic CRUD operations: setItem, getItem, removeItem, clear, and default storage usage.

import storage, { getItem, setItem, removeItem, clear } from 'metal-storage'; // Store a value setItem('key', 'value'); // Retrieve a value const value = getItem('key'); console.log(value); // 'value' // Remove a specific key removeItem('key'); // Clear all stored data clear(); // Using the default storage instance storage.setItem('session', 'data'); console.log(storage.getItem('session')); // 'data'
Debug
Known issues
gotchaThe default storage backend might be null if no global storage (localStorage) is available, e.g., in restrictive environments or SSR.
fix
Check if storage is available before using, or provide a fallback storage adapter.
affects: all
deprecatedSome older methods may be deprecated in future releases; prefer the documented named exports.
fix
Use the canonical named imports for better compatibility.
affects: >=1.0.0
gotchaThe package may throw synchronous errors on quota exceeded or invalid data; wrap in try-catch if needed.
fix
Use try-catch blocks around storage operations.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'metal-storage'
Package not installed or incorrect import path.
fix
Run 'npm install metal-storage' and ensure import path matches.
TypeError: storage.getItem is not a function
Default import is an object, but you might have imported a different thing or used it incorrectly.
fix
Use 'import storage from 'metal-storage'' and then 'storage.getItem()' or named imports.
TypeError: Cannot read property 'getItem' of null
Global storage (localStorage) not available (e.g., in Node.js without a polyfill).
fix
Provide a storage backend that works in your environment, or use a polyfill.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
21 hits · last 30 days
node
20
Amazon
1
Resources
metal-storage — npm install metal-storage · libregistry