npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

amplitude-rn-experiment

v1.8.13

Published

Storage-agnostic React Native Experiment client for Amplitude services

Readme

amplitude-rn-experiment

Storage-agnostic React Native Experiment client compatible with Amplitude services.

This package builds on the original Amplitude React Native Experiment client with a smaller default dependency surface, stronger lifecycle cleanup, and modern React Native compatibility fixes.

Key improvements over the original package:

  • no hard runtime dependency on @react-native-async-storage/async-storage
  • built-in shared memory storage fallback for development and tests
  • preserved custom storage hook for apps that want persistent storage
  • React Native new-architecture support fixes for Android and iOS
  • Android compatibility fixes for modern Gradle and React Native toolchains
  • safer async handling for initialization, polling, retries, and fetch failures
  • cleanup for retry timers, polling timers, and Amplitude identity listeners
  • cache namespace isolation so projects using different deployment keys do not collide
  • defensive cache parsing for malformed persisted values
  • deterministic tests covering lifecycle, storage, and async failure paths

Install

bun add amplitude-rn-experiment

Compatibility

This version is validated against Expo SDK 56 with React Native 0.85.3 and React 19.2.3. The package peer range supports React Native 0.74 through 0.85 and React 18.2 through 19.x.

The iOS package target is 16.4 or newer, matching the Expo SDK 56 native baseline.

Example app

The example app is an Expo SDK 56 prebuild project.

cd example
bun install
bun run doctor -- --verbose
bun run android
bun run ios

Useful validation commands:

bun run typecheck
bunx expo install --check

Default storage behavior

If you initialize the client without a storage implementation, the SDK uses built-in in-memory storage for cached variants and flag data.

That is fine for tests and development.

Do not ship the memory fallback as your production storage strategy if you want cached variants or flag state to survive app restarts.

Usage

import { Experiment } from 'amplitude-rn-experiment';

const client = Experiment.initialize(DEPLOYMENT_KEY);
await client.fetch({ user_id: 'user-1' });

Use fetchOrThrow(user?, options?) when app code needs to observe whether the current fetch completed successfully. It follows the same fetch path as fetch(), stores variants on success, and rejects on timeout, network, HTTP, empty API key, or storage failures. fetch() keeps its upstream-compatible behavior: it logs failures and resolves. If retry is enabled, fetchOrThrow() still rejects the immediate failed call after scheduling the same background retry work used by fetch().

Custom storage

Pass a custom storage implementation to persist variants and flags:

type Storage = {
  get(key: string): Promise<string | null>;
  put(key: string, value: string): Promise<void>;
  delete(key: string): Promise<void>;
  reset?(): Promise<void>;
};

Nitro storage example

import { Experiment } from 'amplitude-rn-experiment';
import { storage, StorageScope } from 'react-native-nitro-storage';

const experimentStorage = {
  async get(key) {
    return storage.getString(key, StorageScope.Disk) ?? null;
  },
  async put(key, value) {
    storage.setString(key, value, StorageScope.Disk);
  },
  async delete(key) {
    storage.deleteString(key, StorageScope.Disk);
  },
};

const client = Experiment.initialize(DEPLOYMENT_KEY, {
  storage: experimentStorage,
});

Exports

  • LocalStorage
  • MemoryStorage

Both names point to the built-in shared in-memory storage implementation in this fork.

Upstream compatibility

The public Experiment API stays close to the upstream React Native client. The main behavioral difference is the default storage backend: this fork defaults to memory instead of AsyncStorage.

Additional fork-only maintenance includes:

  • safe dependency updates for Amplitude connector and Experiment core packages
  • concurrent fetch response ordering protection
  • explicit logger injection support
  • guarded clear and persistence writes so storage errors are logged instead of becoming unhandled promises
  • retry and polling cleanup to avoid dangling timers after stop()
  • Amplitude identity listener cleanup after stop()
  • user-session exposure cache invalidation on identity change
  • example app updates for fewer rerenders, safer unmount handling, and direct AsyncStorage autolinking for the analytics example dependency

Fork lineage

Maintenance policy

This package is maintained as an active fork, not a one-off patch release.

  • upstream changes should be reviewed regularly for compatibility and bug fixes
  • native compatibility regressions should be validated against the example apps
  • storage behavior should remain dependency-free by default and persistence should stay opt-in via custom storage

Validation matrix

| Surface | Verified | | --- | --- | | Upstream Experiment API shape | close to @amplitude/[email protected] | | Package build | bob build | | TypeScript | tsc --noEmit | | Lint | eslint "**/*.{ts,tsx}" | | Built-in memory storage | regression tests | | Custom storage | regression tests | | Stop lifecycle cleanup | regression tests | | Retry and polling cleanup | regression tests | | Cache namespace isolation | regression tests | | Async failure handling | regression tests | | Android manifest permission surface | regression tests | | Expo SDK 56 dependency alignment | expo install --check and expo-doctor | | Android example app | clean debug build and runtime smoke test | | iOS example app | clean simulator build and runtime smoke test |