---
title: "Self-host the browser Session Replay script"
description: Serve a pinned browser Session Replay SDK script from your own CDN or static file server.
product: session-replay
lang: en
token_estimate: 787
---
# Self-host the browser Session Replay script

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

Serve the Session Replay SDK script from your own domain when your browser installation loads the SDK through a `<script>` tag. An npm installation bundled with your app doesn't need this step. Script hosting and [proxying replay requests](https://amplitude.com/docs/session-replay/proxy-replay-requests) are independent tasks.

## Self-host the SDK script

Self-hosting the SDK script applies to browser-based SDKs loaded through a `<script>` tag. If you install through npm and bundle the SDK yourself, skip to [Proxy replay requests](https://amplitude.com/docs/session-replay/proxy-replay-requests).

### Get the SDK file

Option A: Download from Amplitude's CDN:

```bash
# Session Replay Plugin (example version: 1.28.1)
curl -O https://cdn.amplitude.com/libs/plugin-session-replay-browser-1.28.1-min.js.gz

# Session Replay Standalone SDK (example version: 1.39.0)
curl -O https://cdn.amplitude.com/libs/session-replay-browser-1.39.0-min.js.gz

# Browser SDK (example version: 2.42.0 — only needed if also self-hosting analytics)
curl -O https://cdn.amplitude.com/libs/analytics-browser-2.42.0-min.js.gz
```

Option B: Pull from npm:

```bash
pnpm pack @amplitude/plugin-session-replay-browser@1.28.1
# or
pnpm pack @amplitude/session-replay-browser@1.39.0
```

The `pnpm pack` command produces a `.tgz` tarball. Extract the tarball and locate the UMD bundle inside the `package/lib/scripts/` directory, for example, `plugin-session-replay-browser-1.28.1.umd.js`. Serve that file from your own origin.

These examples pin SDK versions. To choose another version, refer to [the plugin package](https://www.npmjs.com/package/@amplitude/plugin-session-replay-browser) or [the standalone package](https://www.npmjs.com/package/@amplitude/session-replay-browser) on npm.

### Serve the file

Host the file on your own CDN or static file server, then update your `<script>` tags:

```html
<!-- Before -->
<script src="https://cdn.amplitude.com/libs/analytics-browser-2.42.0-min.js.gz"></script>
<script src="https://cdn.amplitude.com/libs/plugin-session-replay-browser-1.28.1-min.js.gz"></script>

<!-- After -->
<script src="https://assets.yourdomain.com/libs/analytics-browser-2.42.0-min.js.gz"></script>
<script src="https://assets.yourdomain.com/libs/plugin-session-replay-browser-1.28.1-min.js.gz"></script>
```

> **Tip:** Cache TTL
>
> If you plan to update the SDK version frequently, set a short cache TTL (1 to 5 minutes) on your file server. If you pin to a specific version and update manually, a longer TTL is fine.

## Content Security Policy

If your app sets a Content Security Policy, replace `https://cdn.amplitude.com` in `script-src` with your file-serving domain. Keep `blob:` in `worker-src`, because the Session Replay web worker requires it. If you also proxy network requests, follow the [proxy CSP configuration](https://amplitude.com/docs/session-replay/proxy-replay-requests#content-security-policy-csp).

