Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@flagswift/react-native

Official React Native SDK for FlagSwift feature flags.

Installation

npm install @flagswift/react-native

Required polyfill

React 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-polyfill

And import it once at your app's entry point (e.g. index.js), before anything else:

import 'react-native-url-polyfill/auto'

Quick Start

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 />
}

API

Same hooks as the web React SDK: useFlag, useFlagMeta, useFlagContext, FlagProvider, FlagClient. See full reference.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages