React Native SDK
Reference guide for integrating feature flags into React Native apps.
Setup
Initialize `FlagProvider` at the app root and pass a public client key.
TSTypeScript
import { FlagProvider, useFeatureFlag } from "react-native-featureflags";
function HomeScreen() {
const showUpsell = useFeatureFlag("upsell-v2", false, {
key: "user-123",
attributes: { platform: "ios", appVersion: "1.9.2" },
});
return showUpsell ? <UpsellV2 /> : <UpsellV1 />;
}App lifecycle
- Pause frequent network churn when app is backgrounded.
- Trigger an immediate refresh when app returns to foreground.
- Handle offline mode by keeping last good snapshot.
Bootstrap caching
Persist the most recent snapshot to local storage for faster cold starts.
Performance guidance
- Avoid creating new context objects on every render.
- Keep flag reads close to feature boundaries.
- Use sensible polling intervals to balance freshness and battery usage.