Installation
Setup
Wrap your app withRegistryProvider:
Core Concepts
effect-atom provides React integration for Effect.ts:- Atoms - Observable state containers that can wrap Effects
- Result - Loading/Success/Failure monad for async state
- Hooks -
useAtomValue,useAtomSet,useAtomfor React - Layer integration -
Atom.runtime()to use Effect services
Basic Example: Display Balance
Result Monad
Result has three states for handling async data:
| State | Description |
|---|---|
Initial | Effect hasn’t started or is loading |
Success<A> | Has value, optional waiting flag for refresh |
Failure<E> | Has error cause |
Wallet Connection Example
Mutations with useAtomSet
Atom Families for Dynamic Data
UseAtom.family to create atoms dynamically by key:
Hooks Reference
| Hook | Purpose |
|---|---|
useAtomValue(atom) | Read atom value (returns Result for async atoms) |
useAtomSet(atom) | Get setter function for mutations |
useAtom(atom) | Get [value, setter] tuple |
useAtomRefresh(atom) | Get function to refresh/refetch |
useAtomSuspense(atom) | Suspense-enabled reading (throws promise) |
Best Practices
- Create runtime once at module level, not in components
- Compose layers before creating runtime - don’t chain multiple
Effect.provide - Use
Atom.keepAlivefor data that should persist across unmounts - Use
Atom.familyfor dynamic/parameterized atoms - Use
Atom.refreshOnWindowFocusfor data that should refresh when user returns

