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
- useSelector
- useSetValue
- useAtom
- useStoreActions
- _useStore (experimental)
- useStore (deprecated)
- UseSelectorOptions
AI/LLM: This documentation page is available in plain markdown format at/store/latest/docs/framework/svelte/reference/functions/useAtom.md
Store API Reference
useAtom
ts
function useAtom<TValue>(atom, options?): [{
current: TValue;
}, (fn) => void & (value) => void];Defined in: useAtom.ts:18
Returns the current atom holder together with a setter.
Use this when a component needs to both read and update the same writable atom.
Type Parameters#
TValue#
TValue
Parameters#
atom#
Atom<TValue>
options?#
UseSelectorOptions<TValue>
Returns#
[{ current: TValue; }, (fn) => void & (value) => void]
Example#
ts
const [count, setCount] = useAtom(countAtom)
setCount((prev) => prev + 1)
console.log(count.current)