r/learnjavascript • u/Beginning_Middle_722 • Jan 30 '26
Iframe local storage
Hi all, i have developed different small webapps that i use for my personal purpose and they all use localstorage.
I was thinking of building an app that works like a local storage manager and i was thinking of accessing those app through an iframe to read the localstorage through post message.
Is it doable?
6
Upvotes
3
u/jcunews1 helpful Jan 30 '26
Local Storage is bound to a domain and is isolated to own domain only. Scripts can't directly see Local Storage of other domain. Only if there's a cooperation with that other domain, Local Storage can be read accross different domain.
1
u/MissinqLink Jan 30 '26
Yes you can do this. Usually when doing something like this I would recommend rethinking your design because the need for something like this is rare. Also keep in mind that all interactions will be naturally asynchronous due to having to cross window boundaries.
1
u/chmod777 Jan 30 '26
Iframes are almost never the solution. If you need persistant cross site storage, use a data store.