FeaturevisorFeaturevisor

Framework guides

React Native SDK

Featurevisor SDK can be used with React Native for evaluating feature flags when building iOS and Android applications.

Installation

You can use the same Featurevisor React SDK in your React Native app. Just install it as a regular dependency:

$ npm install --save @featurevisor/react

See @featurevisor/react API docs here.

Example usage

// ./MyComponent.js
import { Text } from "react-native";
import { useFlag } from "@featurevisor/react";

export default function MyComponent() {
  const featureKey = "my_feature";
  const context = { userId: "123" };

  const isEnabled = useFlag(featureKey, context);

  return (
    <Text>Feature is {isEnabled ? "enabled" : "disabled"}</Text>
  );
}

Polyfills

Because Featurevisor's JavaScript SDK uses fetch API internally, it can be used with React Native without any additional dependencies.

The only extra polyfill you might need is for the TextEncoder API.

You can consider using fastestsmallesttextencoderdecoder package for that.

Example repository

You can find a fully functioning example app built with React Native and Featurevisor SDK here: https://github.com/featurevisor/featurevisor-example-react-native.

Previous
React