---
title: Install the JavaScript SDK v6+
slug: feature-experimentation/docs/install-the-javascript-sdk
docTags: 
createdAt: 2026-08-05T20:40:03.000Z
---

The JavaScript SDK can be used in Node, browser, React Native, and other platforms (using the universal bundle) and is distributed through [npm](https://www.npmjs.com/package/@optimizely/optimizely-sdk).

## Minimum SDK version

v6.0.0+

For versions 5.3.5 and below, see [JavaScript (Browser) SDK](docId\:k5-eIbD1aBpIDrLvDA8KH) or [JavaScript (Node) SDK](docId\:aWlYGdCB88CMVFXhGcI2o).

See the [SDK compatibility matrix](docId:2shbZfPCkPAZ0mlZpL1TU) documentation for a list of current SDK releases and the features they support.

## Install

Using `npm`.

```shell
npm install --save @optimizely/optimizely-sdk
```

Using `yarn`.

```shell
yarn add @optimizely/optimizely-sdk
```

Using `pnpm`.

```shell
pnpm add @optimizely/optimizely-sdk
```

Using `deno` (no installation required).

```shell
import optimizely from "npm:@optimizely/optimizely-sdk"
```

## Installation on React Native

For the React Native platform, additional configuration is required. After installing the JavaScript SDK, you need to install the following peer dependencies in your React Native application to enable features like datafile caching and offline event persistence.

```shell
npm install --save \
  @react-native-async-storage/async-storage \
  @react-native-community/netinfo \
  react-native-get-random-values \
  fast-text-encoding
```

- `@react-native-async-storage/async-storage` – Used to enable datafile caching by storing the datafile locally on the user's device. It also enables offline event persistence by temporarily storing events while the device is offline. However, using this package is optional, you can provide your own custom cache implementation instead.
- `@react-native-community/netinfo` – Required to detect changes in internet connectivity. Ensures that any events triggered while offline are retried when connectivity is restored.
- `react-native-get-random-values` – Required to support the `crypto.getRandomValues()` API.
- `fast-text-encoding` – Required to support encoding functionality used in user bucketing.

If you prefer to use a different persistent caching solution instead of `@react-native-async-storage/async-storage`, you can pass your own implementation that conforms to the `Store<string>` interface in the following cases:

1. **Polling config manager** – If you are using the [polling project config manager](docId:2bQ4KAFcVOAesqDOcmtCZ), provide your custom `cache` implementation in the config.
2. **Batch event processor** – If you are using the [batch event processor](docId:2bQ4KAFcVOAesqDOcmtCZ), provide your custom `eventStore` in the config.

By doing this, you can avoid installing `@react-native-async-storage/async-storage` and instead use your own implementation to handle caching and event storage.

The full JavaScript SDK source code is available on [GitHub](https://github.com/optimizely/javascript-sdk/tree/master).

## Next

After installing, you must [initialize the SDK](docId:2bQ4KAFcVOAesqDOcmtCZ).
