Movatterモバイル変換


[0]ホーム

URL:


Dev guideRecipesAPI ReferenceChangelog
Dev guideAPI ReferenceRecipesChangelogUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog InFeature Experimentation
Dev guide
All
Pages
Start typing to search…

Install the JavaScript SDK v6+

The steps necessary to install the Optimizely Feature Experimentation JavaScript SDK into your application.

The JavaScript SDK can be used in Node, browser, React Native, and other platforms (using the universal bundle) and is distributed throughnpm.

Minimum SDK version

v6.0.0+

For versions 5.3.5 and below, seeJavaScript (Browser) SDK orJavaScript (Node) SDK.

See theSDK compatibility matrix documentation for a list of current SDK releases and the features they support.

Install

Usingnpm.

npm install --save @optimizely/optimizely-sdk

Usingyarn.

yarn add @optimizely/optimizely-sdk

Usingpnpm.

pnpm add @optimizely/optimizely-sdk

Usingdeno (no installation required).

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.

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 once connectivity is restored.
  • react-native-get-random-values – Required to support thecrypto.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 theStore<string> interface in the following cases:

  1. Polling config manager – If you are using thepolling project config manager, provide your customcache implementation in the config.
  2. Batch event processor – If you are using thebatch event processor, provide your customeventStore 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 onGitHub.

Next

After installing, you mustinitialize the SDK.

Updated 17 days ago



[8]ページ先頭

©2009-2025 Movatter.jp