Open History to see the last commit
1---
2id: useAtom
3title: useAtom
4---
5β
6```ts
7function useAtom<TValue>(atom, options?): [Accessor<TValue>, (fn) => void & (value) => void];
8```
9β
10Defined in: node\_modules/.pnpm/@tanstack+solid-store@0.11.1\_solid-js@1.9.14/node\_modules/@tanstack/solid-store/dist/useAtom.d.ts:23
11β
12Returns the current atom accessor together with a setter.
13β
14Use this when a component needs to both read and update the same writable
15atom.
16β
17## Type Parameters
18β
19### TValue
20β
21`TValue`
22β
23## Parameters
24β
25### atom
26β
27[`Atom`](../interfaces/Atom.md)\<`TValue`\>
28β
29### options?
30β
31[`UseSelectorOptions`](../interfaces/UseSelectorOptions.md)\<`TValue`\>
32β
33## Returns
34β
35\[`Accessor`\<`TValue`\>, (`fn`) => `void` & (`value`) => `void`\]
36β
37## Example
38β
39```tsx
40const [count, setCount] = useAtom(countAtom)
41β
42return (
43 <button type="button" onClick={() => setCount((prev) => prev + 1)}>
44 {count()}
45 </button>
46)
47```