Platform and versions
Choose the web, React Native or shared core package, check requirements, and configure server rendering.
Packages
| Package | Use it for | Persistence |
|---|---|---|
react-global-state-hooks | Web apps. | localStorage |
react-native-global-state-hooks | React Native. | Async storage (optional peer dependency) |
react-hooks-global-states | The shared core, without a storage layer. | None |
The web and React Native packages build on the core package and re-export its API.
Requirements
- React 18 or newer (
react >= 18). The core package also listsreact-dom >= 18. - The web package needs
json-storage-formatter^4 (installed with it). - React Native:
react-native >= 0.69and, for persistence,@react-native-async-storage/async-storage >= 1.17.11.
Version
Server rendering
- On the server,
localStorageis not available, so persistence is skipped and stores start from their initial state. - A global store is a module singleton. On a server it is shared between requests; keep per-request data in a context instead.
- Persisted values restore before hydration in the browser. See Persistence.