Next, update your app’s default function (Usually App.tsx or Layout.tsx) so that the StatsigProvider wraps around all child components.
import { StatsigProvider } from "@statsig/react-bindings"; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( <StatsigProvider sdkKey={"client-MY-STATSIG-CLIENT-KEY"} user={{ userID: "quickstart-user" }} loadingComponent={<div>Loading...</div>}> {children} </StatsigProvider> );}
This example assumes you’re using client-side React, if you’re Server-Side Rendering, you’d be better served by our Next.js docs.
3
Add client key
Create a client API key in the Statsig console Settings. Copy and paste it to replace <REPLACE_WITH_YOUR_CLIENT_KEY> in the code snippet from the previous step.
4
Basic Usage
Check a Gate
Get an Experiment Value
Log an Event
First, create a gate on the Feature Gates page in console, then check it in-code:
Congratulations! You’ve successfully set up the Statsig SDK in React. Continue on to the tutorials, or jump in to the full Next.js or React SDK libraries.
1
Paste the code snippet
In the <head> section of your website, paste the following code snippet:
Create a client API key in the Statsig console Settings. Copy and paste it to replace <REPLACE_WITH_YOUR_CLIENT_KEY> in the code snippet from the previous step.
3
Basic usage
Check a Gate
Get an Experiment Value
Log an Event
First, create a gate on the Feature Gates page in console, then check it in-code:
You’ll want to wait for the SDK to initialize before checking a gate to ensure it has fresh values, one way to accomplish this is waiting for the “values_updated” event.
You’ll want to wait for the SDK to initialize before getting an experiment to ensure it has fresh values, one way to accomplish this is waiting for the “values_updated” event.
You can use Events to power metrics in your experiment or gates. Events don’t need to be set up in console first, just add to your code:
Create a server secret key in the Statsig console Settings. Copy and paste it to replace <REPLACE_WITH_YOUR_SERVER_SECRET_KEY> in the code snippet from the previous step.
4
Basic Usage
Check a Gate
Get an Experiment Value
Log an Event
First, create a gate on the Feature Gates page in console, then check it in-code:
user_object = StatsigUser(user_id="123", email="testuser@statsig.com") //add any number of other attributesgate_value = statsig.check_gate(user_object, "my_feature_gate_name"):
Congratulations! You’ve set up the Statsig SDK in Python. Continue on to our tutorials, or jump in to the full Python SDK Reference.
1
Install the Statsig package
npm i @statsig/statsig-node-core
2
// Basic initializationconst statsig = new Statsig("<REPLACE_WITH_YOUR_SERVER_SECRET_KEY>");await statsig.initialize();// or with StatsigOptionsconst options: StatsigOptions = { environment: "staging" };const statsigWithOptions = new Statsig("secret-key", options);await statsigWithOptions.initialize();
3
Add server secret key
Create a server secret key in the Statsig console Settings. Copy and paste it to replace <REPLACE_WITH_YOUR_SERVER_SECRET_KEY> in the code snippet from the previous step.
4
Basic Usage
Check a Gate
Get an Experiment Value
Log an Event
First, create a gate on the Feature Gates page in console, then check it in-code: