Official React Native SDK for FlagSwift feature flags.
npm install @flagswift/react-nativeReact Native's JS engine (Hermes) doesn't include URL/URLSearchParams by default on all versions. If you see a URL is not defined error, add:
npm install react-native-url-polyfillAnd import it once at your app's entry point (e.g. index.js), before anything else:
import 'react-native-url-polyfill/auto'import { FlagProvider, FlagClient } from '@flagswift/react-native'
const client = new FlagClient({
apiKey: 'fs_client_your_key_here',
environment: 'production',
userIdentifier: 'user@example.com',
})
export default function App() {
return (
<FlagProvider client={client}>
<YourApp />
</FlagProvider>
)
}import { useFlag } from '@flagswift/react-native'
function Screen() {
const showNewUI = useFlag('new-checkout')
return showNewUI ? <NewCheckoutScreen /> : <OldCheckoutScreen />
}Same hooks as the web React SDK: useFlag, useFlagMeta, useFlagContext, FlagProvider, FlagClient. See full reference.
MIT