npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@featbit/react-native-sdk

v1.0.2

Published

FeatBit client SDK for React Native

Downloads

93

Readme

FeatBit Client-Side SDK for React Native

Introduction

This is the React Native SDK for the feature management platform FeatBit.

Be aware, this is a client side SDK, it is intended for use in a single-user context, which can be mobile, desktop or embeded applications. This SDK is designed to be used for React Native projects.

The React Native SDK is based on the React Client SDK
The React Native SDK builds on FeatBit's React Client SDK (the latter depends on the JavaScript client SDK) to provide a better integration for use in React Native applications. As a result, much of the React Client SDK and JavaScript SDK functionality is also available for the React Native SDK to use.

Getting started

Install

npm install @featbit/react-native-sdk

Prerequisite

Before using the SDK, you need to obtain the environment secret and SDK URLs.

Follow the documentation below to retrieve these values

Quick Start

The following code demonstrates:

  1. Initialize the SDK
  2. Evaluate flag with userFlags hook
// src/TestComponent.tsx
import React from 'react';
import {Text, View} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
import {useFlags} from '@featbit/react-client-sdk';

export default function TestCompoment({isDarkMode}: {isDarkMode: boolean}) {
    const {robot} = useFlags();
    return (
        <View
            style={[
                {
                    marginTop: 32,
                    paddingHorizontal: 24,
                },
            ]}>
            {robot === 'AlphaGo' && (
                <Text
                    style={[
                        {
                            color: isDarkMode ? Colors.white : Colors.black,
                            textAlign: 'center',
                            fontSize: 30,
                            fontWeight: '700',
                        },
                    ]}>
                    AlphaGo 🤖
                </Text>
            )}
        </View>
    );
}

// App.tsx
import React from 'react';
import {
    SafeAreaView,
    useColorScheme
} from 'react-native';
import type { PropsWithChildren } from 'react';
import {buildConfig, withFbProvider} from '@featbit/react-native-sdk';
import TestCompoment from './src/TestComponent.tsx';

function App(): React.JSX.Element {
    const isDarkMode = useColorScheme() === 'dark';

    const backgroundStyle = {
        backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
    };

    return (
        <SafeAreaView style={backgroundStyle}>
            <TestCompoment isDarkMode={isDarkMode} />
        </SafeAreaView>
    )
}

const options = {
    user: {
        name: 'the user name',
        keyId: 'fb-demo-user-key',
        customizedProperties: []
    },
    sdkKey: 'YOUR ENVIRONMENT SECRET',
    streamingUrl: 'THE STREAMING URL',
    eventsUrl: 'THE EVENTS URL'
};

export default withFbProvider(buildConfig({options}))(App);

Examples

SDK

The React Native SDK depends on the React Client SDK, please refer to the React Client SDK for more information. The Main difference between the React Client SDK and the React Native SDK is the way the SDK is initialized.

Initializing the SDK

After you install the dependency, initialize the React SDK. You can do this in one of two ways:

  • Using the asyncWithFbProvider function
  • Using the withFbProvider function

Before using either of the above ways, you need to create a IOption object and please make sure that you have called the buildConfig function with the IOption object as an argument.

function App(): React.JSX.Element {
    // The App component code ...
}

const options = {
    user: {
        name: 'the user name',
        keyId: 'fb-demo-user-key',
        customizedProperties: []
    },
    sdkKey: 'YOUR ENVIRONMENT SECRET',
    streamingUrl: 'THE STREAMING URL',
    eventsUrl: 'THE EVENTS URL'
};

// This line is needed to initialize the SDK
const config = buildConfig({options});

export default withFbProvider(config)(App);