# Install Statsig Session Replay

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.

{% callout type="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.
{% /callout %}

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

{% tabs %}
{% tab title="Javascript" %}
{% codetabs %}
```bash npm
npm install @statsig/js-client @statsig/session-replay @statsig/web-analytics
```

```bash yarn
yarn add @statsig/js-client @statsig/session-replay @statsig/web-analytics
```
{% /codetabs %}
{% /tab %}

{% tab title="React" %}
{% codetabs %}
```bash npm
npm install @statsig/session-replay @statsig/web-analytics @statsig/react-bindings
```

```bash yarn
yarn add @statsig/session-replay @statsig/web-analytics @statsig/react-bindings
```
{% /codetabs %}
{% /tab %}
{% /tabs %}

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:

{% tabs %}
{% tab title="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();
```
{% /tab %}

{% tab title="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>
  );
}
```
{% /tab %}
{% /tabs %}

{% callout type="info" %}
To use Conditional Triggers, you must use `StatsigTriggeredSessionReplay`. Refer to Configure (next page) for more information.
{% /callout %}

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