Skip to main content

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.

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.