Skip to main content
Module

x/jotai/docs/guides/using-store-outside-react.mdx

👻 Primitive and flexible state management for React
Go to Latest
File
---title: Using store outside Reactdescription: Using store outside Reactnav: 4.98keywords: state, outside, reactpublished: false---
Jotai's state resides in React, but sometimes it would be niceto interact with the world outside React.
## createStore
[`createStore`](../core/store.mdx#createstore) provides a store interface that can be used to store your atoms. Using the store, you can access and mutate the state of your stored atoms from outside React.
```jsximport { atom, useAtomValue, createStore, Provider } from 'jotai'
const timeAtom = atom(0)const store = createStore()
store.set(timeAtom, (prev) => prev + 1) // Update atom's valuestore.get(timeAtom) // Read atom's value
function Component() { const time = useAtomValue(timeAtom) // Inside React return ( <div className="App"> <h1>{time}</h1> </div> )}
export default function App() { return ( <Provider store={store}> <Component /> </Provider> )}```
### Examples
<CodeSandbox id="2jvynm" />