Get Started with the Statsig SDKs
This quickstart will guide you through quickly installing the Statsig SDK in a client app. If you're looking for a more detailed guide, check out the SDK Overview or read about choosing between client vs. server SDKs.
React
JS snippet
Python
Node
... +24 more
1. Install Statsig packages
npm install @statsig/react-bindings
2. Import the StatsigProvider
In your App Router, import the StatsigProvider.
import StatsigProvider from "@statsig/react-bindings";
3. Wrap child components
Next, update your app's default function so that the StatsigProvider wraps around all child components.
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<StatsigProvider
sdkKey={process.env.NEXT_PUBLIC_STATSIG_CLIENT_KEY!}
user={{ userID: "quickstart-user" }}
}}>
{children}
</StatsigProvider>
);
}
4. 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.
5. Next steps
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.
The easiest way to get up and running is by adding the Statsig JavaScript snippet to your website.
1. Paste the code snippet
In the <head>
section of your website, paste the following code snippet.
<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 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.
3. Next steps
Congratulations! You've set up the Statsig JavaScript snippet. Once installed, you'll be able to:
- Start recording events.
- Watch session replays.
- Run experiments.
- Use feature flags.
1. Install Statsig packages
pip install statsig-python-core
2. Initialize the Statsig SDK
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 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. Next steps
Congratulations! You've successfully set up the Statsig SDK in Python. Continue on to the tutorials, or jump in to the full Python SDK library.
1. Install Statsig packages
npm i @statsig/statsig-node-core
2. Initialize the Statsig SDK
// 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 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. Next steps
Congratulations! You've successfully set up the Statsig SDK in Node.js. Continue on to the tutorials, or jump in to the full Node.js SDK library.