---
title: Use Multiple Instances of the Mobile SDK
description: >-
  Configure and manage multiple named instances of RUM mobile SDKs for complex
  application architectures and multi-tenant scenarios.
breadcrumbs: >-
  Docs > RUM & Session Replay > Real User Monitoring & Session Replay Guides >
  Use Multiple Instances of the Mobile SDK
---

# Use Multiple Instances of the Mobile SDK

## Overview{% #overview %}

{% alert level="info" %}
In order to use multiple instances of the SDK, you will need to adopt version `2.0.0` or higher. See the [Upgrade RUM Mobile SDKs](https://docs.datadoghq.com/real_user_monitoring/guide/mobile-sdk-upgrade) guide.
{% /alert %}

Follow this guide to use multiple named instances of the SDK. Many methods of the SDK optionally take an SDK instance as an argument. If none is provided, the call is associated with the default (nameless) SDK instance.

**Note**: The SDK instance name should be consistent between application runs. Storage paths for SDK events depend on this.

**Note**: Session Replay can only run on a single core at once. To switch to a different one, first stop the existing core it is running on.

{% tab title="Android" %}

```kotlin
val namedSdkInstance = Datadog.initialize("myInstance", context, configuration, trackingConsent)

val userInfo = UserInfo(...)
Datadog.setUserInfo(userInfo, sdkCore = namedSdkInstance)

Logs.enable(logsConfig, namedSdkInstance)
val logger = Logger.Builder(namedSdkInstance)
    // ...
    .build()

Trace.enable(traceConfig, namedSdkInstance)

// OpenTelemetry (recommended)
val tracer  = GlobalOpenTelemetry.get().getTracer("...")

// Datadog API
val tracer = DatadogTracing.newTracerBuilder(namedSdkInstance)
    // ...
    .build()

Rum.enable(rumConfig, namedSdkInstance)
GlobalRumMonitor.get(namedSdkInstance)

NdkCrashReports.enable(namedSdkInstance)

WebViewTracking.enable(webView, allowedHosts, namedSdkInstance)

SessionReplay.enable(sessionReplayConfig, namedSdkInstance)
```

**Note**: In order for instrumentation to work on the WebView component, it is very important that the JavaScript is enabled on the WebView. To enable it, you can use the following code snippet:

```kotlin
webView.settings.javaScriptEnabled = true
```

You can retrieve the named SDK instance by calling `Datadog.getInstance(<name>)` and use the `Datadog.isInitialized(<name>)` method to check if the particular SDK instance is initialized.
{% /tab %}

{% tab title="iOS" %}

```swift
import DatadogCore
import DatadogRUM
import DatadogLogs
import DatadogTrace

let core = Datadog.initialize(
    with: configuration,
    trackingConsent: trackingConsent,
    instanceName: "my-instance"
)

RUM.enable(
    with: RUM.Configuration(applicationID: "<RUM Application ID>"),
    in: core
)

Logs.enable(in: core)

Trace.enable(in: core)

SessionReplay.enable(with: sessionReplayConfig, in: core)
```

Once the named SDK instance is initialized, you can retrieve it by calling `Datadog.sdkInstance(named: "<name>")` and use it as shown below.

```swift
import DatadogCore

let core = Datadog.sdkInstance(named: "my-instance")
```

### Logs{% #logs %}

```swift
import DatadogLogs

let logger = Logger.create(in: core)
```

### Trace{% #trace %}

```swift
import DatadogRUM

let monitor = RUMMonitor.shared(in: core)
```

### RUM{% #rum %}

```swift
import DatadogRUM

let monitor = RUMMonitor.shared(in: core)
```

{% /tab %}

## Further Reading{% #further-reading %}

- [Visualize your RUM data in the Explorer](https://docs.datadoghq.com/real_user_monitoring/explorer)
