Skip to content

An SDK for using Statsig Feature Management and Experimentation platform in React js clients

License

Notifications You must be signed in to change notification settings

blstrco/statsig-react-sdk

 
 

Repository files navigation

Statsig React Client SDK

npm version

🚧 This is the Linkree fork of statsig-react lib 🚧

The main goal of this fork is to provide lazy loading approach for loading statsig-js js bundle

How to use it?

At first, you need to import StatsigLazyProvider

 import { StatsigLazyProvider } from '@linktr.ee/statsig-react/StatsigLazyProvider'

 <StatsigLazyProvider
   sdkKey={`client-${STATSIG_CLIENT_SECRET}`}
   stage={STAGE}
   user={{ userID: account.uuid, privateAttributes: { email: account.emailAddress } }}
 >

Then you can use all official hooks from the docs in the children components. For example:

import { useExperiment } from '@linktr.ee/statsig-react/useExperiment';

const { loading, config } = useExperiment('footer_cta_button');

Additionally, we added the improved useExperiment where you can pass the default value in order to have more strict types

import { useExperimentValue } from '@linktr.ee/statsig-react/useExperimentValue';

const { loading, value } = useExperimentValue(
  'footer_cta_button',
  'variation',
  'control',
);

About fork architecture, local development and others, please see the Fork Development section

The Statsig React SDK for single user client environments. If you need a SDK for another language or server environment, check out our other SDKs.

Statsig helps you move faster with feature gates (feature flags), and/or dynamic configs. It also allows you to run A/B/n tests to validate your new features and understand their impact on your KPIs. If you're new to Statsig, check out our product and create an account at statsig.com.

Getting Started

Check out our SDK docs to get started.

🚧 This is the Linkree fork of statsig-react lib. This development guide contains specifics which are not related to the official statsig react sdk 🚧

Fork Development Guide

Architecture

(contains only fork changes)

Local development

We're planning to add support of yarn link, but right now you can publish a new alfa version from your local PC. At first, you need to compile it and then publish:

  • npm run prepare
  • npm run publish-custom-version

Please make sure that you change the version in the package.json to the alfa -for example - 1.34.0-alpha.96

Test amd Styleguide

  • npm test for unit testing
  • npm run styleguide for checking prettier and eslint rules
    • npm run styleguide:fix for fixing prettier and eslint issues

About

An SDK for using Statsig Feature Management and Experimentation platform in React js clients

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • TypeScript 98.8%
  • JavaScript 1.2%