Web Storage works under Nub without a flag to remember. Node hides sessionStorage and localStorage behind --experimental-webstorage on the 22.4–24 band (native from 25), so Nub injects that flag for you on exactly that band — you never pass it. 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, never touching disk. It works out of the box on Node 22.4+ — nothing to pass:

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

A short walkthrough of a multi-step flow within one run:

sessionStorage.setItem("cursor", "0");

for (const page of pages) {
  const seen = Number(sessionStorage.getItem("cursor"));
  process(page, seen);
  sessionStorage.setItem("cursor", String(seen + 1));
}

console.log(sessionStorage.getItem("cursor")); // pages.length

Captured from Nub on Node 22.15.0 (no flag, no file passed):

$ nub session.ts
1
length 1

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 you do, localStorage is undefined, so typeof localStorage === "undefined" is a feature check. Name a backing file and the global comes alive:

localStorage.setItem("token", "abc123");
localStorage.getItem("token");        // "abc123"
localStorage.length;                  // 1
localStorage.key(0);                  // "token"
localStorage.removeItem("token");
localStorage.clear();

Values survive between runs:

$ 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.

Your explicit webstorage flag wins

If you pass --experimental-webstorage (or --no-experimental-webstorage) yourself, Nub respects it and injects nothing. The version band is encoded in crates/nub-core/src/node/flags.rs: the flag exists from Node 22.4.0, is required through 24.x, and is unflagged from 25.0.0 on.