Client Only - Local Storage
I created a global store that's backed by window.localstorage. I don't think that I can use
clientOnly
because the module doesn't export an Element. What do I do?
4 Replies
i guess that i can move the localstorage part into a component.
Use
makePersisted
from @solid-primitives/storage
, it will automatically persist any signal or store for you and even just return it if there is no storage given (localStorage is the default, none on the server).you can use the
isServer
if you dont need the state to be available and renderable on the server.
BUT i think what you are searching for is better suited as a standalone primitive such as the one provided by @solid-primitives
or something homemade and simpler
which you can then use
you can also import the module in onMount
with dynamic import()