# Installation (/docs/sdk/installation)



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](/docs/sdk#get-your-app-id).

Prefer to let an AI do it? [Prompt your coding agent](/docs/sdk/agent-prompt) bundles these same steps into a ready-to-paste prompt for Claude, Cursor, or any coding agent.

<Callout type="info">
  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](/docs/sdk/tracking-events) for the events worth sending.
</Callout>

<Tabs items="['Expo', 'React Native', 'iOS', 'Android', 'Flutter', 'Web', 'Node']">
  <Tab value="Expo">
    <Steps>
      <Step>
        **Install dependencies**

        ```sh
        npm install @layers/expo @layers/react-native expo-tracking-transparency expo-linking
        ```
      </Step>

      <Step>
        **Add the plugin to `app.json`**

        Add the Layers plugin to the `plugins` array under `expo`:

        ```json
        {
          "expo": {
            "plugins": [
              ["@layers/react-native/plugin", {
                "ios": { "attUsageDescription": "Helps show personalized content." },
                "enableDebug": true
              }]
            ]
          }
        }
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```ts
        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>
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab value="React Native">
    <Steps>
      <Step>
        **Install dependencies**

        ```sh
        npm install @layers/react-native @react-native-community/netinfo @react-native-async-storage/async-storage
        cd ios && pod install
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```ts
        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 });
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab value="iOS">
    <Steps>
      <Step>
        **Add the Swift Package**

        ```swift
        // Package.swift
        .package(url: "https://github.com/layers/layers-sdk-ios.git", from: "1.0.0")
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```swift
        import Layers

        Layers.initialize(config: LayersConfig(
            appId: "YOUR_APP_ID",
            environment: .production
        ))

        Layers.track("purchase_success", properties: ["product_id": "premium", "revenue": 9.99])
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab value="Android">
    <Steps>
      <Step>
        **Add the dependency**

        ```kotlin
        // build.gradle.kts
        implementation("io.layers.sdk:layers-android:2.0.0-alpha.1")
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```kotlin
        // 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))
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab value="Flutter">
    <Steps>
      <Step>
        **Add the dependency**

        ```yaml
        # pubspec.yaml
        dependencies:
          layers_flutter: ^0.1.0
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```dart
        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});
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab value="Web">
    <Steps>
      <Step>
        **Install the package**

        ```sh
        npm install @layers/client
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```ts
        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 });
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab value="Node">
    <Steps>
      <Step>
        **Install the package**

        ```sh
        npm install @layers/node
        ```
      </Step>

      <Step>
        **Initialize and track events**

        ```ts
        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 });
        ```
      </Step>
    </Steps>

    <Callout type="info">
      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.
    </Callout>
  </Tab>
</Tabs>

## Next [#next]

* [Tracking events](/docs/sdk/tracking-events) — the standard events, their properties, and identifying users.
* [Attribution](/docs/sdk/attribution) — how installs are attributed, and the iOS-specific settings.
* [SDK health & verification](/docs/api/concepts/sdk-health) — confirm tracking is healthy end-to-end.
