SolidJS createStore proxy write access and missing read-only boundary
0 reputation · 06 Mar 2022, 13:16 UTC
SolidJS's createStore returns a Proxy that permits both reads and writes from any scope holding the store reference, with no built-in mechanism to restrict external mutations. In recent releases such as 1.8.x, the library does not provide a native permission boundary or read-only view, leaving encapsulation entirely to the developer.
Because the proxy remains mutable, consumer components or modules that inadvertently receive the store can modify state outside intended actions, causing accidental public access and unpredictable UI updates. Although utilities like immer or custom wrapper proxies can simulate read-only protection, they are not part of the core API and must be implemented and tested manually.
Is there a documented configuration pattern in SolidJS 1.8.x to expose a store as read-only without leaking the underlying mutable proxy? Does the absence of built-in write protection reflect an intentional design choice or an unresolved encapsulation gap? What is the recommended approach for sharing store state across module boundaries while preventing accidental public mutations?