Skip to content
react-global-state-hooks

Platform and versions

Choose the web, React Native or shared core package, check requirements, and configure server rendering.

GuideTypeScriptTry an example

Packages

PackageUse it forPersistence
react-global-state-hooksWeb apps.localStorage
react-native-global-state-hooksReact Native.Async storage (optional peer dependency)
react-hooks-global-statesThe 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 lists react-dom >= 18.
  • The web package needs json-storage-formatter ^4 (installed with it).
  • React Native: react-native >= 0.69 and, for persistence, @react-native-async-storage/async-storage >= 1.17.11.

Version

Server rendering

  • On the server, localStorage is 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.
Documentation
↑↓ Navigate ↵ Open Esc CloseRGSH docs
Get started

Shared state. Precise subscriptions.
Built-in DevTools.