Unified SDK for React Native reference

This reference documents every public export of @amplitude/unified-react-native and every option you can pass to init(), verified against version 1.0.0-beta.11. That version bundles @amplitude/analytics-react-native 1.13.0, @amplitude/plugin-experiment-react-native 1.0.0-beta.12, and @amplitude/plugin-session-replay-react-native 0.5.12. For changes between versions, go to the @amplitude/unified-react-native changelog.

ts
import * as amplitude from "@amplitude/unified-react-native";

The top-level functions act on a default client. Each client from createInstance() has the same methods.

Exports

Unified SDK exports

React Native SDK exports

These work as in the React Native SDK reference: add, extendSession, flush, getDeviceId, getSessionId, getUserId, groupIdentify, identify, logEvent, remove, reset, revenue, setDeviceId, setGroup, setOptOut, setSessionId, setUserId, track, trackScreenView, trackScreenViewOnNavigationStateChange, createNetworkRequestEvent, Identify, Revenue, and Types.

The package doesn't export ampCapture. Import it from @amplitude/analytics-react-native. For details, go to Track element interactions.

Type-only exports

UnifiedClient, UnifiedOptions, and UnifiedSharedOptions are TypeScript types, with no runtime value.

Setup

init

Initializes Analytics, then Feature Experiment, Session Replay, and Guides and Surveys. Call it once.

ts
init(apiKey: string, options?: UnifiedOptions): Promise<void>

init() returns a plain Promise, not { promise } like the analytics methods. It resolves after every product finishes, and never rejects. Later calls return the first call's promise without changing anything. Failures go to the analytics logger as Failed to initialize <product>.

ts
await amplitude.init("AMPLITUDE_API_KEY", {
  serverZone: "EU",
  sessionReplay: { sampleRate: 0.1 },
});

experiment

Returns the Feature Experiment client, or undefined before init() finishes.

ts
experiment(): IExperimentClient | undefined
ts
const variant = amplitude.experiment()?.variant("checkout-redesign");

For the client's methods, such as fetch(), variant(), all(), and exposure(), go to the Experiment React Native SDK.

sessionReplay

Returns the Session Replay plugin, or undefined before init() finishes or when Session Replay failed to install.

ts
sessionReplay(): SessionReplayPlugin | undefined
ts
await amplitude.sessionReplay()?.stop();

createInstance

Creates another client with its own analytics instance.

ts
createInstance(): UnifiedClient

Clients share one Guides and Surveys plugin: the first client to initialize sets its API key and engagement options.

ts
const secondary = amplitude.createInstance();
await secondary.init("OTHER_API_KEY", { instanceName: "secondary" });

UnifiedClient

The type of the default client and of each createInstance() client. It has every React Native SDK client method except init, plus:

UnifiedOptions

Shared options

Top-level options apply to several products. A value in a product block overrides the top-level value for that product.

Guides and Surveys receives logLevel as a lowercase string, such as "warn".

Product options

experiment options

sessionReplay options

For masking behavior, go to the Session Replay React Native plugin.

AmpMaskView

A view that sets Session Replay masking for its children.

AmpMaskView accepts every React Native View prop.

Was this helpful?

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

On this page