Skip to content

Native global state for React

Shared React state, without a state framework.
native-state-react is a small global state library for React. Initialize store with <Root>, read or update state with two hooks.
Section titled “native-state-react is a small global state library for React. Initialize store with <Root>, read or update state with two hooks.”
Terminal window
npm install native-state-react
const [name, setName] = useNativeState('state.user.name','James');

Get started

Install the package, initialize your state, and build a working first example. Start here

Understand state paths

Learn how paths like state.user.name and state.todos[0].done address values. Read the guide

Pick the right hook

Use useNativeState to read and write, or useNativeSelector to read only. Compare selectors

There is one module-level store. <Root> seeds it once; components subscribe to values with useNativeState or useNativeSelector. String paths are the simplest way to read a specific value and update it.

The library is deliberately small. It does not provide reducers, middleware, persistence, devtools, or separate store instances. Read behavior and limitations before using it with server-rendered or multi-root apps.