solara icon indicating copy to clipboard operation
solara copied to clipboard

Accessing the localStorage of a browser

Open JovanVeljanoski opened this issue 1 year ago • 1 comments

Does solara provide access to (read/write/modify) the browsers "localStorage" ?

Thanks

JovanVeljanoski avatar Sep 04 '24 22:09 JovanVeljanoski

Hi Jovan,

no, we do not support that out of the box (although we would be interested in supporting it with reactive variables, but it's tricky to get the details right for general use). However, a component can be made to sync to localstorage, e.g.: https://py.cafe/maartenbreddels/solara-localstorage

The downside is that the initial render will be done with the default value, and (quickly) once the page renders, we set the value. I hope that is sufficient for your needs right now. Otherwise cookies might be a good solution, since you have direct access to that. I'll answer that in #773.

cheers,

Maarten

maartenbreddels avatar Sep 05 '24 08:09 maartenbreddels

Hi,

Thank you for this example - also shows me stuff about how to make other vue components. This is a neat example and basically what I want - thank you! Although the double-render at the start could be improved upon one day perhaps!

Feel free to close this if you think it is done, or keep it open until there is an official implementation/support for this - as you see fit.

Thank you!

JovanVeljanoski avatar Nov 06 '24 02:11 JovanVeljanoski