Installation
Install and initialize the Layers SDK on Expo, React Native, iOS, Android, Flutter, Web, or Node — install the package, initialize with your App ID, and send your first event.
Pick your platform below. Each guide installs the package, initializes the SDK with your App ID, and sends a first event. Replace YOUR_APP_ID with the value from your project's Events screen — see Get your App ID.
Prefer to let an AI do it? Prompt your coding agent bundles these same steps into a ready-to-paste prompt for Claude, Cursor, or any coding agent.
The SDK auto-tracks sessions and app-lifecycle events once initialized. The
track() call in each snippet is just to prove the pipe works — see
Tracking events for the events worth sending.
Install dependencies
npm install @layers/expo @layers/react-native expo-tracking-transparency expo-linkingAdd the plugin to app.json
Add the Layers plugin to the plugins array under expo:
{
"expo": {
"plugins": [
["@layers/react-native/plugin", {
"ios": { "attUsageDescription": "Helps show personalized content." },
"enableDebug": true
}]
]
}
}Initialize and track events
import { LayersReactNative } from '@layers/expo';
const layers = new LayersReactNative({
appId: 'YOUR_APP_ID',
enableDebug: __DEV__,
});
useEffect(() => {
layers.init();
}, []);
// Track events
layers.track('purchase_success', { product_id: 'premium', revenue: 9.99 });
// Or wrap your tree with LayersProvider for React context:
// import { LayersProvider } from '@layers/expo';
// <LayersProvider client={layers}>...</LayersProvider>Install dependencies
npm install @layers/react-native @react-native-community/netinfo @react-native-async-storage/async-storage
cd ios && pod installInitialize and track events
import { LayersReactNative } from '@layers/react-native';
const layers = new LayersReactNative({
appId: 'YOUR_APP_ID',
enableDebug: __DEV__,
});
useEffect(() => {
layers.init();
}, []);
layers.track('purchase_success', { product_id: 'premium', revenue: 9.99 });Add the Swift Package
// Package.swift
.package(url: "https://github.com/layers/layers-sdk-ios.git", from: "1.0.0")Initialize and track events
import Layers
Layers.initialize(config: LayersConfig(
appId: "YOUR_APP_ID",
environment: .production
))
Layers.track("purchase_success", properties: ["product_id": "premium", "revenue": 9.99])Add the dependency
// build.gradle.kts
implementation("io.layers.sdk:layers-android:2.0.0-alpha.1")Initialize and track events
// Application.onCreate()
LayersAndroid.configure(this) {
appId = "YOUR_APP_ID"
environment = Environment.PRODUCTION
}
LayersAndroid.track("purchase_success", mapOf("product_id" to "premium", "revenue" to 9.99))Add the dependency
# pubspec.yaml
dependencies:
layers_flutter: ^0.1.0Initialize and track events
import 'package:layers_flutter/layers_flutter.dart';
await Layers.init(LayersConfig(
appId: 'YOUR_APP_ID',
environment: 'production',
));
await Layers.track('purchase_success', properties: {'product_id': 'premium', 'revenue': 9.99});Install the package
npm install @layers/clientInitialize and track events
import { LayersClient } from '@layers/client';
const layers = new LayersClient({
appId: 'YOUR_APP_ID',
environment: 'production',
});
await layers.init();
await layers.track('purchase_success', { product_id: 'premium', revenue: 9.99 });Install the package
npm install @layers/nodeInitialize and track events
import { LayersNode } from '@layers/node';
const layers = new LayersNode({
appId: 'YOUR_APP_ID',
});
await layers.init();
// Node takes a per-call distinctId as the first argument
await layers.track('user-123', 'purchase_success', { product_id: 'premium', revenue: 9.99 });Node is server-side, so there's no ambient user. Every call takes the user's
distinctId as its first argument — the client SDKs infer it from the
active session instead.
Next
- Tracking events — the standard events, their properties, and identifying users.
- Attribution — how installs are attributed, and the iOS-specific settings.
- SDK health & verification — confirm tracking is healthy end-to-end.
Overview
The Layers SDK instruments your app for attribution and event tracking — install it once per platform, then track the events that matter. Available for Expo, React Native, iOS, Android, Flutter, Web, and Node.
Prompt your coding agent
A ready-to-paste prompt that instructs Claude, Cursor, or any coding agent to install and instrument the Layers SDK in your app — install, initialize, and track the events that matter.