Skip to content

React Native

native-state-react uses React hooks and does not access browser or DOM APIs, so its state API can be used in React Native components.

Install the package in your app:

Terminal window
npm install native-state-react

Initialize the store near the root of your component tree:

import { Root } from 'native-state-react';
export default function AppRoot() {
return (
<Root initial={{ user: { name: 'Mary' } }}>
<App />
</Root>
);
}

Then use the same hooks and paths as on the web:

import { Text } from 'react-native';
import { useNativeSelector } from 'native-state-react';
function Greeting() {
const name = useNativeSelector('state.user.name');
return <Text>Hello, {name}</Text>;
}

The package peer-declares React 18.2 or React 19, as well as react-dom. Check your package manager’s peer dependency output when installing into a React Native project. The library itself does not call React DOM APIs.

The store is still a single module-level store; React Native does not add multiple-store or per-screen isolation. See behavior and limitations.