Effect v4 Atom with SolidJS
The official @effect/atom-solid package connects Effect v4’s core Atom and AtomRef modules to SolidJS. It provides reactive accessors, setters, subscriptions, and registry scoping without an Effectify wrapper package.
Installation
Section titled “Installation”Configuration
Section titled “Configuration”Use RegistryProvider when atom state should be scoped to a Solid subtree. Without a provider, the hooks use the default standalone registry.
Basic Usage
Section titled “Basic Usage”Create an Atom
Section titled “Create an Atom”Import Atom from Effect v4’s reactivity modules.
useAtom
Section titled “useAtom”useAtom reads and writes an atom, similarly to Solid’s createSignal. Atom hooks accept a thunk so they can follow Solid’s reactive ownership model.
useAtomValue
Section titled “useAtomValue”Use useAtomValue when a component only needs a reactive accessor. An optional selector derives a value.
Advanced Usage
Section titled “Advanced Usage”Write without subscribing
Section titled “Write without subscribing”Subscribe or keep an atom mounted
Section titled “Subscribe or keep an atom mounted”useAtomSubscribe runs a callback for changes, while useAtomMount keeps an atom mounted for the lifetime of the current Solid owner.
Seed and refresh values
Section titled “Seed and refresh values”Work with AtomRef
Section titled “Work with AtomRef”AtomRef is part of Effect v4 core. useAtomRef subscribes a Solid accessor directly to a ref.
API overview
Section titled “API overview”RegistryProvider: Scopes an atom registry to a Solid subtree.useAtom(() => atom): Returns a reactive accessor and setter.useAtomValue(() => atom, selector?): Returns a reactive accessor.useAtomSet(() => atom): Returns a setter without subscribing to the value.useAtomSubscribe(() => atom, callback): Subscribes to changes.useAtomMount(() => atom): Keeps an atom mounted for the current Solid owner.useAtomInitialValues(values): Seeds atoms in the current registry.useAtomRefresh(() => atom): Returns a refresh callback.useAtomResource(() => atom): Converts anAsyncResultatom into a Solid resource.useAtomRef(() => ref): Subscribes to anAtomRef.useAtomRefProp(() => ref, key): Derives a property ref.useAtomRefPropValue(() => ref, key): Subscribes to a property value.