Yes you can use it very easily with a package "node-localstorage"
npm install node-localstorage
Use in React :
import { LocalStorage } from "node-localstorage";
global.localStorage = new LocalStorage('./scratch');
Use JavaScript:
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'));