Store Docs
API Reference
Store API Reference
- Store
- ReadonlyStore
- Atom
- AtomOptions
- BaseAtom
- InternalBaseAtom
- InternalReadonlyAtom
- InteropSubscribable
- Readable
- ReadonlyAtom
- StoreActionsApi
- Subscribable
- Subscription
- AnyAtom
- Observer
- Selection
- StoreAction
- StoreActionMap
- StoreActionsFactory
- batch
- createAsyncAtom
- createAtom
- createStore
- flush
- shallow
- toObserver
- createStoreContext
- useCreateAtom
- useCreateStore
- useSelector
- useAtom
- UseSelectorOptions
AI/LLM: This documentation page is available in plain markdown format at/store/latest/docs/framework/octane/reference/functions/useAtom.md
Store API Reference
useAtom
ts
function useAtom<TValue>(
atom,
options?,
): [TValue, Atom<TValue>['set']];Defined in: useAtom.ts:17
Returns the current atom value together with a stable setter.
This is the writable-atom convenience hook for components that need to both read and update the same atom.
Type Parameters#
TValue#
TValue
Parameters#
atom#
Atom<TValue>
options?#
UseSelectorOptions<TValue>
Returns#
[TValue, Atom<TValue>["set"]]
Example#
tsx
const [count, setCount] = useAtom(countAtom)