
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
node-localstorage
Advanced tools
A drop-in substitute for the browser native localStorage API that runs on node.js.
Copyright (c) 2012, Lawrence S. Maccherone, Jr.
A drop-in substitute for the browser native localStorage API that runs on node.js.
localStorage['myKey'] = 'myValue' and dot property localStorage.myKey = 'myValue'
syntax if you are in an ES6 supported environment._sync() files can be re-read from disk. This is useful if you are using more
than one process to access the same storage location.Author: Larry Maccherone
unless localStorage?
{LocalStorage} = require('../') # require('node-localstorage') for you
localStorage = new LocalStorage('./scratch')
localStorage.setItem('myFirstKey', 'myFirstValue')
console.log(localStorage.getItem('myFirstKey'))
# myFirstValue
localStorage._deleteLocation() # cleans up ./scratch created during doctest
Open or create src/setupTests.js and add these two lines:
// /src/setupTests.js
import { LocalStorage } from "node-localstorage";
global.localStorage = new LocalStorage('./scratch');
if (typeof localStorage === "undefined" || localStorage === null) {
var LocalStorage = require('node-localstorage').LocalStorage;
localStorage = new LocalStorage('./scratch');
}
localStorage.setItem('myFirstKey', 'myFirstValue');
console.log(localStorage.getItem('myFirstKey'));
Polyfil your node.js environment with this as the global localStorage when launching your own code
node -r node-localstorage/register my-code.js
npm install node-localstorage
_sync() (thanks @create3000 for the report)_sync() method (thanks @NexusNull)npm publishnewThe localStorage package provides a similar API to node-localstorage but is designed to be a more lightweight and minimalistic solution. It offers basic localStorage functionalities but may lack some of the more advanced features and configurability of node-localstorage.
The node-persist package offers a more feature-rich and flexible solution for persistent storage in Node.js. It supports various storage backends and provides additional features like data expiration and encryption, making it a more robust alternative to node-localstorage.
The electron-store package is designed specifically for Electron applications but can also be used in Node.js. It provides a simple API for persistent storage and supports JSON schema validation, making it a good choice for applications that require more structured data storage.
FAQs
A drop-in substitute for the browser native localStorage API that runs on node.js.
The npm package node-localstorage receives a total of 443,623 weekly downloads. As such, node-localstorage popularity was classified as popular.
We found that node-localstorage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.