Node hides sessionStorage and localStorage behind --experimental-webstorage on the 22.4–24 band (native from 25); Nub injects that flag on exactly that band. Below Node 22.4 the flag does not exist and Web Storage is unavailable.

Read the full docs for Web Storage on developer.mozilla.org.

sessionStorage

The sessionStorage global is in-memory and per-process: it is created fresh each run and discarded when the process exits.

sessionStorage.setItem("step", "1");
sessionStorage.getItem("step");      // "1"
sessionStorage.length;               // 1
sessionStorage.key(0);               // "step"
sessionStorage.removeItem("step");
sessionStorage.clear();

localStorage

The localStorage global persists across runs, so it needs a file on disk to write to. Pass --localstorage-file <path> and Nub forwards it to Node verbatim; until then localStorage is undefined, so typeof localStorage === "undefined" is a feature check.

localStorage.setItem("token", "abc123");
localStorage.getItem("token");        // "abc123"
localStorage.length;                  // 1
localStorage.key(0);                  // "token"
localStorage.removeItem("token");
localStorage.clear();
$ nub --localstorage-file=./app.db write.ts
abc123
$ nub --localstorage-file=./app.db read.ts
abc123

The --localstorage-file flag is also honored when set in NODE_OPTIONS.

Explicit flags

If you pass --experimental-webstorage (or --no-experimental-webstorage) yourself, Nub respects it and injects nothing. The flag exists from Node 22.4.0, is required through 24.x, and is unflagged from 25.0.0 on.