---
title: Statsig SDK Quickstart Guide
description: Get data flowing into Statsig with only a few lines of code.
product: general
token_estimate: 3073
---
# Statsig SDK Quickstart Guide

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

This quickstart guide is meant to get your implementation up and running as quickly as possible. Because of that, it only implements a standardized set of information. For a more detailed guide, go to the [Statsig SDK Getting Started](https://docs.statsig.com/sdks/getting-started) guide or read about choosing between [client or server SDKs](https://docs.statsig.com/sdks/client-vs-server).

#### React

1. **Install Statsig packages**

   ```bash
   npm install @statsig/react-bindings
   ```
2. **Wrap your child components**

   Update your app's default function (typically App.tsx or Layout.tsx) so that the StatsigProvider component identifier wraps all child components.

   ```tsx
   import { StatsigProvider } from "@statsig/react-bindings"; // [!code ++]

   export default function RootLayout({ children }: { children: React.ReactNode }) {
     return (
       <StatsigProvider // [!code ++]
         sdkKey={"client-MY-STATSIG-CLIENT-KEY"} // [!code ++]
         user={{ userID: "quickstart-user" }} // [!code ++]
         loadingComponent={<div>Loading...</div>}> // [!code ++]
         {children}
       </StatsigProvider> // [!code ++]
     );
   }
   ```

   > **Note:**
   >
   > This example assumes client-side React. For server-side rendering, refer to the [Next.js docs](https://docs.statsig.com/client/Next).
3. **Add a client key**

   Create a client API key in the [Statsig console Settings](https://console.statsig.com/api_keys). Copy and paste it to replace `<REPLACE_WITH_YOUR_CLIENT_KEY>` in the code snippet from the previous step.
4. **Confirm the basic functions are working**

   #### Check a Gate

   Create a gate on the [Feature Gates page](https://console.statsig.com/gates) in console and confiirm it works from within the code:

   ```jsx
   const { client } = useStatsigClient();
   return (
     <div>Gate is {client.checkGate('check_user') ? 'passing' : 'failing'}.</div>
   );
   ```

   #### Get an Experiment Value

   Create an Experiment on the [Experiments page](https://console.statsig.com/experiments) with the console:

   ```jsx
   const { client } = useStatsigClient();
   const experiment = client.getExperiment('my_experiment_name');

   return (
     <div>Headline Parameter: {experiment.get('my_experiment_parameter_name', 'fallback_value')}.</div>
   );
   ```

   #### Log an Event

   Use events to power metrics in your experiment or gates. You don't need to set up events in console first. Add them to your code:

   ```jsx
   const { client } = useStatsigClient();
   return <button onClick={() => client.logEvent("button_click")}>Click Me</button>
   ```

## Next steps

You've set up the Statsig SDK in React. Continue with the SDK Quickstart tutorials, or go to the full [Next.js](https://docs.statsig.com/client/Next) or [React](https://docs.statsig.com/client/React) SDK reference.

#### JS snippet

1. **Paste the code snippet**

   In the `<head>` section of your website, paste the following code snippet:

   ```html
   <script src="https://cdn.jsdelivr.net/npm/@statsig/js-client@3/build/statsig-js-client+session-replay+web-analytics.min.js?apikey=<REPLACE_WITH_YOUR_CLIENT_KEY>"></script>
   ```
2. **Add a client key**

   Create a client API key in the [Statsig console Settings](https://console.statsig.com/api_keys). Copy and paste it to replace `<REPLACE_WITH_YOUR_CLIENT_KEY>` in the code snippet from the previous step.
3. **Confirm the basic functions are working**

   #### Check a Gate

   First, create a gate on the [Feature Gates page](https://console.statsig.com/gates) in console and confiirm it works from within the code:

   ```jsx
   window.Statsig.instance().checkGate("my_feature_gate_name");
   ```

   > **Note:**
   >
   > Wait for the SDK to initialize before checking a gate to ensure it has fresh values. One way to do this is to wait for the ["values\_updated"](https://docs.statsig.com/client/javascript-sdk#client-event-emitter) event.

   #### Get an Experiment Value

   First, create an Experiment on the [Experiments page](https://console.statsig.com/experiments) from within your console:

   ```jsx
   window.Statsig.instance().getExperiment("my_experiment_name").get('my_experiment_parameter_name');
   ```

   > **Note:**
   >
   > Wait for the SDK to initialize before getting an experiment to ensure it has fresh values. One way to do this is to wait for the ["values\_updated"](https://docs.statsig.com/client/javascript-sdk#client-event-emitter) event.

   #### Log an Event

   Use events to power metrics in your experiment or gates. You don't need to set up events in console first. Add them to your code:

   ```jsx
   window.Statsig.instance().logEvent("my_checkout_event_name", "event_value_item_1234", {"event_metadata": "my_metadata"})
   ```

## Next steps

You've set up the Statsig JavaScript snippet. You can now:

- [Record events](https://docs.statsig.com/webanalytics/overview)
- [Watch session replays](https://docs.statsig.com/session-replay/overview)
- [Run experiments](https://docs.statsig.com/experiments/overview)
- [Use feature flags](https://docs.statsig.com/feature-flags/overview)

Go to the [Javascript SDK reference](https://docs.statsig.com/client/javascript-sdk) for more information.

#### Python

1. **Install the Statsig package**

   ```shell
   pip install statsig-python-core
   ```
2. **Initialize the Statsig SDK**

   ```python
   from statsig_python_core import Statsig, StatsigOptions

   options = StatsigOptions()
   options.environment = "development"

   statsig = Statsig("<REPLACE_WITH_YOUR_SERVER_SECRET_KEY>", options)
   statsig.initialize().wait()

   statsig.shutdown().wait()
   ```
3. **Add a server secret key**

   Create a server secret key in the [Statsig console Settings](https://console.statsig.com/api_keys). Copy and paste it to replace `<REPLACE_WITH_YOUR_SERVER_SECRET_KEY>` in the code snippet from the previous step.
4. **Confirm the basic functions are working**

   #### Check a Gate

   First, create a gate on the [Feature Gates page](https://console.statsig.com/gates) in console and confiirm it works from within the code:

   ```python
   user_object = StatsigUser(user_id="123", email="testuser@statsig.com") //add any number of other attributes
   gate_value = statsig.check_gate(user_object, "my_feature_gate_name"):
   ```

   #### Get an Experiment Value

   First, create an Experiment on the [Experiments page](https://console.statsig.com/experiments) from within your console:

   ```python
   user_object = StatsigUser(user_id="123", email="testuser@statsig.com"
   my_experiment_object = statsig.get_experiment(user_object, "my_experiment_name")
   my_experiment_parameter_value = my_experiment_object.get_string('my_experiment_parameter_name')
   ```

   #### Log an Event

   Use events to power metrics in your experiment or gates. You don't need to set up events in console first. Add them to your code:

   ```python
   user_object = StatsigUser(user_id="123", email="testuser@statsig.com"

   statsig.log_event(
     user=user_object,
     event_name="my_checkout_event_name",
     value="SKU_12345"
   )
   ```

## Next steps

You've set up the Statsig SDK in Python. Continue with the SDK quickstart tutorials, or go to the full [Python SDK Reference](https://docs.statsig.com/server-core/python-core).

#### Node

1. **Install the Statsig package**

   ```bash
   npm i @statsig/statsig-node-core
   ```
2. **Initialize the Statsig SDK**

   ```jsx
   // Basic initialization
   const statsig = new Statsig("<REPLACE_WITH_YOUR_SERVER_SECRET_KEY>");
   await statsig.initialize();

   // or with StatsigOptions
   const options: StatsigOptions = { environment: "staging" };

   const statsigWithOptions = new Statsig("secret-key", options);
   await statsigWithOptions.initialize();
   ```
3. **Add a server secret key**

   Create a server secret key in the [Statsig console Settings](https://console.statsig.com/api_keys). 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

   First, create a gate on the [Feature Gates page](https://console.statsig.com/gates) in console and confiirm it works from within the code:

   ```js
   const userObject = new StatsigUser({ userID: "123", email="testuser@statsig.com" });
   const is_gate_enabled = statsig.checkGate(userObject, "my_feature_gate_name"):
   ```

   #### Get an Experiment Value

   First, create an Experiment on the [Experiments page](https://console.statsig.com/experiments) from within your console:

   ```js
   const userObject = new StatsigUser({ userID: "123", email="testuser@statsig.com" });
   const myExperimentObject = statsig.getExperiment(userObject, "my_experiment_name")
   const myExperimentParameterValue = myExperimentObject.getValue('my_experiment_parameter_name')
   ```

   #### Log an Event

   Use events to power metrics in your experiment or gates. You don't need to set up events in console first. Add them to your code:

   ```js
   userObject = StatsigUser(user_id="123", email="testuser@statsig.com"

   statsig.logEvent(
     userObject,
     "my_checkout_event_name",
     "SKU_12345" //value for the event
   );
   ```

## Next steps

You've set up the Statsig SDK in Node.js. Continue with the SDK quickstart tutorials, or go to the full [Node.js SDK reference](https://docs.statsig.com/server-core/node-core).

#### +24 more SDKs

## Explore SDKs

Statsig offers SDKs for a wide variety of platforms:

### Client-side SDKs

### [JavaScript](https://docs.statsig.com/client/javascript-sdk)

Browser JavaScript

### [React](https://docs.statsig.com/client/React)

Client-Side React

### [React Native](https://docs.statsig.com/client/ReactNative)

Bare React Native SDK

### [Next.js](https://docs.statsig.com/client/Next)

Next.js SSR, SSG & Client-Side

### [Angular](https://docs.statsig.com/client/Angular)

Angular bindings for Javascript SDK

### [Swift](https://docs.statsig.com/client/iosClientSDK)

iOS, MacOS, tvOS SDK

### [Android](https://docs.statsig.com/client/Android)

Android Kotlin/Java SDK

### [.NET Client](https://docs.statsig.com/client/DotNet)

Client SDK for .NET framework

### [Roku](https://docs.statsig.com/client/Roku)

Roku Brightscript SDK

### [Unity](https://docs.statsig.com/client/Unity)

Unity game engine SDK

### [Dart/Flutter](https://docs.statsig.com/client/Dart)

Flutter/Dart Mobile App SDK

### [C++ Client](https://docs.statsig.com/client/CPP)

C++ client-side SDK

### Server-side SDKs

### [Node.js](https://docs.statsig.com/server-core/node-core)

Node.js server SDK

### [Java](https://docs.statsig.com/server-core/java-core)

Java server SDK

### [Python](https://docs.statsig.com/server-core/python-core)

Python server SDK

### [Go](https://docs.statsig.com/server/go)

Go server SDK

### [Ruby](https://docs.statsig.com/server/ruby)

Ruby server SDK

### [.NET Server](https://docs.statsig.com/server-core/dotnet-core)

.NET server SDK

### [PHP](https://docs.statsig.com/server-core/php-core)

PHP server SDK

### [Rust](https://docs.statsig.com/server-core/rust-core)

Rust server SDK

### [C++ Server](https://docs.statsig.com/server-core/cpp-core)

C++ server SDK

### Integrations

### [Webflow](https://docs.statsig.com/guides/webflow-sidecar-ab-test)

Webflow integration

### [Shopify](https://docs.statsig.com/guides/shopify-ab-test)

Shopify integration

### [Segment](https://docs.statsig.com/integrations/data-connectors/segment)

Segment data connector

### [Rudderstack](https://docs.statsig.com/integrations/data-connectors/rudderstack)

Rudderstack connector

### [Hightouch](https://docs.statsig.com/integrations/data-connectors/hightouch)

Hightouch integration

### [mParticle](https://docs.statsig.com/integrations/data-connectors/mparticle)

mParticle connector

### [Framer](https://docs.statsig.com/guides/framer-analytics)

Framer integration

### [Slack](https://docs.statsig.com/integrations/slack)

Slack notifications

### [Integrations](https://docs.statsig.com/integrations/introduction)

View more integrations

