---
title: Install Statsig Session Replay
description: "Install Statsig Session Replay by adding the plugin to your JavaScript or React client SDK and configuring sampling, privacy, and capture options."
product: session-replay
token_estimate: 831
---
# Install Statsig Session Replay

> 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`.

Statsig supports Session Replay on the Javascript and React SDKs for both desktop and mobile web users. Follow the instructions below to install the SDK and record user sessions.

## Option 1 - No code - Add Javascript snippet to your website

```html
<script src="https://cdn.jsdelivr.net/npm/@statsig/js-client@3/build/statsig-js-client+session-replay+web-analytics.min.js?apikey=[YOUR_CLIENT_KEY]"></script>
```

Get YOUR\_CLIENT\_KEY from _Project Settings > Keys & Environments_. Reveal the Client API Key, copy, and paste it over the \[YOUR-API-KEY\] in the snippet above.

This auto-initializes the SDK and starts recording sessions, no code required.

> **Info:**
>
> To use your existing Statsig integration or customize further, refer to option 2 below. To use the script tag with customization, remove your key from the script URL and initialize using the JavaScript code below.

## Option 2 - Custom code - Install using a package manager

#### Javascript

#### npm

```bash
npm install @statsig/js-client @statsig/session-replay @statsig/web-analytics
```

#### yarn

```bash
yarn add @statsig/js-client @statsig/session-replay @statsig/web-analytics
```

#### React

#### npm

```bash
npm install @statsig/session-replay @statsig/web-analytics @statsig/react-bindings
```

#### yarn

```bash
yarn add @statsig/session-replay @statsig/web-analytics @statsig/react-bindings
```

Statsig recommends Autocapture for getting started quickly. To skip automatic event logging, remove the `runStatsigAutoCapture` option from the JavaScript snippet or skip the `@statsig/web-analytics` package installation.

Next, following the [instructions for the Statsig Javascript SDK](https://docs.statsig.com/client/javascript-sdk), initialize Statsig with your SDK key, [user](https://docs.statsig.com/sdks/user) and options:

#### Javascript

```jsx
import { StatsigClient } from "@statsig/js-client";
import { runStatsigSessionReplay } from "@statsig/session-replay";
import { runStatsigAutoCapture } from "@statsig/web-analytics";

const client = new StatsigClient(
  sdkKey,
  { userID: "some_user_id" },
  { environment: { tier: "production" } } // optional, pass options here if needed
);
runStatsigSessionReplay(client);
runStatsigAutoCapture(client);
await client.initializeAsync();
```

#### React

```jsx
import { StatsigProvider, useClientAsyncInit } from "@statsig/react-bindings";
import { StatsigSessionReplayPlugin } from "@statsig/session-replay";
import { StatsigAutoCapturePlugin } from "@statsig/web-analytics";

function App() {
  return (
    <StatsigProvider
      sdkKey={YOUR_CLIENT_KEY}
      user={{ userID: "a-user" }}
      loadingComponent={<div>Loading...</div>}
      options={{
        plugins: [
          new StatsigSessionReplayPlugin(),
          new StatsigAutoCapturePlugin(),
        ],
      }}
    >
      <Content />
    </StatsigProvider>
  );
}
```

> **Info:**
>
> To use Conditional Triggers, you must use `StatsigTriggeredSessionReplay`. Refer to Configure (next page) for more information.

Continue to Configure to learn more about controlling who, what, and when you record sessions.

