Why is my localStorage behaving like sessionStorage?

Long time user of localStorage in other environments (so I know how it works)

I’m trying to show my 12 CompSci classes how to use localStorage in Replit. I can see that the key value pair is being set but when I close the Replit window and come back to it again, the localStorage values are gone - i.e., they’re stored for the session only?!?

Is this a limitation within Replit?

Repl here: https://localstorage-1.alcaughey.repl.co/

Hi @AlCaughey , welcome to the forums!
Do you mean writing to a file?
Where are you running this from?

1 Like

Hi @AlCaughey!

I can’t seem to reproduce this issue on my end.

No, they mean using localStorage.


It depends where you’re running it. Your website should work fine, but it may be finicky if you’re trying to run that in the Replit editor’s WebView tab. (It has a different weird domain that might clear and stuff.)

If it’s happening in the full website window, check your settings and make sure replit.com and *.repl.co can store cookies.

Otherwise, please upload a screen recording of it (and also try checking the localStorage value in the DevTools console occassionally).


I don’t think localStorage works in iframes, so it wouldn’t work at all in the webview.

(Whoops, didn’t realise this was 9 days old…)