(deprecated) statsig-react-native-expo client sdk
To get started with Statsig in Expo, you should use the new Statsig Expo SDK
.
This version of the SDK is deprecated and will only receive major bug fixes going forward. Official support ends Jan 31, 2025.
If you already use this deprecated version, you should check out the migration docs.
Statsig client side SDK for applications in React Native using Expo. If you are not using Expo, check out our plain React Native SDK. This SDK is based on our JavaScript client SDK.
Installation
You can install the SDK via npm or yarn. In your project directory, run:
- NPM
- Yarn
npm install statsig-react-native-expo
yarn add statsig-react-native-expo
Next you can import Statsig in your code and use it away!
import {
StatsigProvider,
useGate,
useExperiment,
useConfig,
Statsig,
} from "statsig-react-native-expo";
If you run into build errors, see the FAQ below.
Usage
v4.X.X of our react-native-expo SDK wraps the statsig-react sdk. It contains the same React Context, Providers, and Hooks, used in the same way. Get started with our suggested usage or the Provider and Hooks details.
Be sure to update the imports from the examples on the react SDK docs to use "statsig-react-native-expo" instead of "statsig-react"
FAQ
If you get build errors when trying to install and use the SDK for the first time, you may need to install a few dependencies and rebuild with a clean cache. We've only encountered these errors when using eas
to build an expo app, but perhaps there are other build tools that will be missing these dependencies.
For example:
Error: [@RNC/AsyncStorage]: NativeModule: AsyncStorage is null
Means you need to install the AsyncStorage dependency
npx expo install @react-native-async-storage/async-storage
And this:
ERROR [Statsig] An unexpected exception occurred. [TypeError: Cannot read property 'getRandomBase64String' of undefined]
Means you need to install the random values depedency:
npx expo install expo-random
Finally, you can clear the cache in an eas
build like this:
eas build -p ios --clear-cache
For non eas
users, you may need to do a pod install
in the ios
folder of your app as well.