> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Aliasing users

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

<Warning>
  **This feature is deprecated for SDKs that use contexts**

  LaunchDarkly no longer supports `alias` events for SDKs upgraded for contexts. LaunchDarkly continues to support sending and receiving alias events for older SDK versions. To learn more, read about our [SDKs that support contexts](/docs/sdk).

  To learn how to associate contexts without using the `alias` method, read [Associate anonymous contexts with logged-in end users](/docs/home/flags/anonymous-contexts#associate-anonymous-contexts-with-logged-in-end-users).
</Warning>

This topic explains how to alias the users of various LaunchDarkly SDKs. This feature is available for both client-side and server-side SDKs, although its behavior differs between client-side and server-side SDKs.

## Aliased users

There are situations in which multiple LaunchDarkly users can represent one person. For example, this can happen when a person initially logs into an application. The person might be represented by an anonymous user before they log in, and a different user after they log in. In that case, that one person is identified by two different users as denoted by different user keys. Our SDKs can associate these two LaunchDarkly users by sending an `alias` event.

Only some LaunchDarkly SDKs offer the ability to manually send an `alias` event. Some client-side SDKs automatically send an `alias` event when identifying a known user if the previous user was anonymous. You can disable this behavior if necessary. To learn how, read [SDK configuration](/docs/sdk/features/config).

Details about each SDK's configuration are available in the SDK-specific sections below:

* [Client-side SDKs](#client-side-sdks)
* [Server-side SDKs](#server-side-sdks)

## Client-side SDKs

This feature is no longer supported or required in any client-side SDKs. To learn more, read [Best practices for upgrading users to contexts](/docs/guides/flags/upgrading-contexts), and consult the [custom contexts migration guide](/docs/sdk) for each client-side SDK.

Older versions of these SDKs still support aliasing. Details for these older versions are included below.

### .NET (client-side)

In version 3 and newer of the .NET (client-side) SDK, aliasing is no longer supported or required. To learn more, read [.NET (client-side) SDK 2.x to 3.0 migration guide](/docs/sdk/client-side/dotnet/migration-2-to-3).

<Accordion title="Expand .NET (client-side) code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```csharp title=".NET SDK 2.x (C#)" lines wrap theme={null}
    client.Alias(newUser, previousUser);
    ```
  </CodeGroup>

  To learn more, read [`LdClient.Alias`](https://launchdarkly.github.io/dotnet-core/pkgs/sdk/client/api/LaunchDarkly.Sdk.Client.LdClient.html#LaunchDarkly_Sdk_Client_LdClient_Alias_) and [`ConfigurationBuilder.AutoAliasingOptOut`](https://launchdarkly.github.io/dotnet-core/pkgs/sdk/client/api/LaunchDarkly.Sdk.Client.LdClient.html#LaunchDarkly_Sdk_Client_ConfigurationBuilder_AutoAliasingOptOut_).
</Accordion>

### Android

In version 4.0 and newer of the Android SDK, aliasing is no longer supported or required. To learn more, read the [Android SDK 3.x to 4.0 migration guide](/docs/sdk/client-side/android/migration-3-to-4).

<Accordion title="Expand Android code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```java title="Java" lines wrap theme={null}
    client.alias(newUser, previousUser);
    ```

    ```kotlin title="Kotlin" lines wrap theme={null}
    client.alias(newUser, previousUser)
    ```
  </CodeGroup>
</Accordion>

### C++ (client-side)

In version 3 and newer of the C++ (client-side) SDK, aliasing is no longer supported or required. To learn more, read [C++ (client-side) SDK 2.x to 3.0 migration guide](/docs/sdk/client-side/c-c--/migration-2-to-3).

<Accordion title="Expand C++ (client-side) code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```c title="C SDK v2.0 (native)" lines wrap theme={null}
    LDClientAlias(client, newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### Electron

<Accordion title="Expand Electron code sample">
  To manually send an `alias` event:

  <CodeGroup>
    ```js title="JavaScript" lines wrap theme={null}
    client.alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### Flutter

In version 2 and newer of the Flutter SDK, aliasing is no longer supported or required. To learn more, read the [Flutter SDK 1.x to 2.0 migration guide](/docs/sdk/client-side/flutter/migration-1-to-2).

<Accordion title="Expand Flutter code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```dart title="Dart" lines wrap theme={null}
    await LDClient.alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### iOS

In version 8 and newer of the iOS SDK, aliasing is no longer supported or required. To learn more, read the [iOS SDK 7.x to 8.0 migration guide for Objective-C](/docs/sdk/client-side/ios/migration-7-to-8-objc) or for [Swift](/docs/sdk/client-side/ios/migration-7-to-8-swift).

<Accordion title="Expand iOS code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```swift title="Swift" lines wrap theme={null}
    LDClient.get()!.alias(context: newUser, previousContext: previousUser)
    ```

    ```objectivec title="Objective-C" lines wrap theme={null}
    [[LDClient get] alias:newUser previousContext:previousUser];
    ```
  </CodeGroup>
</Accordion>

### JavaScript

In version 3 and newer of the JavaScript SDK, aliasing is no longer supported or required. To learn more, read [JavaScript SDK 2.x to 3.0 migration guide](/docs/sdk/client-side/javascript/migration-2-to-3).

<Accordion title="Expand JavaScript code sample for older versions">
  Both `alias` parameters must have `key` attributes. If the LaunchDarkly client auto-generated a unique identifier for one of your users, you can access the user's complete object with the `getUser` method.

  To manually send an `alias` event:

  <CodeGroup>
    ```js title="JavaScript SDK v2.x" lines wrap theme={null}
    const previousUser = client.getUser();
    client.alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### Node.js (client-side)

In version 3 and newer of the Node.js SDK, aliasing is no longer supported or required. To learn more, read [Node.js (client-side) SDK 2.x to 3.0 migration guide](/docs/sdk/client-side/node-js/migration-2-to-3).

<Accordion title="Expand Node.js (client-side) code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```js title="JavaScript" lines wrap theme={null}
    client.alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### React Native

In version 7 and newer of the React Native SDK, aliasing is no longer supported or required. To learn more, read [React Native SDK 6.x to 7.0 migration guide](/docs/sdk/client-side/react/migration-6-to-7-react-native).

<Accordion title="Expand React Native code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```js title="JavaScript" lines wrap theme={null}
    client.alias(user, previousUser);

    // to send an alias event in a different environment than the default,
    // pass in the environment key (optional)
    client.alias(user, previousUser, environment);
    ```
  </CodeGroup>
</Accordion>

### Roku

In version 2 and newer of the Roku SDK, aliasing is no longer supported or required. To learn more, read [Roku SDK 1.x to 2.0 migration guide](/docs/sdk/client-side/roku/migration-1-to-2).

<Accordion title="Expand Roku code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```brightscript title="BrightScript" lines wrap theme={null}
    client.alias(user, previousUser)
    ```
  </CodeGroup>
</Accordion>

## Server-side SDKs

This feature is available in the following server-side SDKs:

* [Apex](#apex)

### .NET (server-side)

In version 7.0 and newer of the .NET (server-side) SDK, aliasing is no longer supported or required. To learn more, read [.NET (server-side) SDK 6.x to 7.0 migration guide](/docs/sdk/server-side/dotnet/migration-6-to-7).

<Accordion title="Expand .NET (server-side) code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```csharp title=".NET SDK v7.0 and earlier (C#)" lines wrap theme={null}
    client.Alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### Apex

<Accordion title="Expand Apex code sample">
  To manually send an `alias` event:

  <CodeGroup>
    ```java title="Apex" lines wrap theme={null}
    client.alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### C++ (server-side)

In version 3.0 and newer of the C++ (server-side) SDK, aliasing is no longer supported or required. To learn more, read [C++ (server-side) SDK 2.x to 3.0 migration guide](/docs/sdk/server-side/c-c--/migration-2-to-3).

<Accordion title="Expand C++ (server-side) code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```c title="C++" lines wrap theme={null}
    LDClientAlias(client, newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### Erlang

In version 2 and newer of the Erlang SDK, aliasing is no longer supported or required. To learn more, read [Erlang SDK 1.x to 2.0 migration guide](/docs/sdk/server-side/erlang/migration-1-to-2).

<Accordion title="Expand Erlang code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```erlang title="Erlang" lines wrap theme={null}
    ldclient:alias(User, PreviousUser)
    ```
  </CodeGroup>
</Accordion>

### Go

In version 6.0 and newer of the Go SDK, aliasing is no longer supported or required. To learn more, read [Go SDK 5.x to 6.0 migration guide](/docs/sdk/server-side/go/migration-5-to-6).

<Accordion title="Expand Go code sample for older versions">
  To manually send an `alias` event in older versions of the Go SDK:

  <CodeGroup>
    ```go title="Go SDK v5.x and earlier" lines wrap theme={null}
    client.Alias(newUser, previousUser)
    ```
  </CodeGroup>
</Accordion>

### Haskell

In version 4 and newer of the Haskell SDK, aliasing is no longer supported or required. To learn more, read [Haskell SDK 3.x to 4.0 migration guide](/docs/sdk/server-side/haskell/migration-3-to-4).

<Accordion title="Expand Haskell code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```haskell title="Haskell" lines wrap theme={null}
    alias client newUser previousUser
    ```
  </CodeGroup>
</Accordion>

### Java

In version 6 and newer of the Java SDK, aliasing is no longer supported or required. To learn more, read [Java SDK 5.x to 6.0 migration guide](/docs/sdk/server-side/java/migration-5-to-6).

<Accordion title="Expand Java code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```java title="Java SDK v5.x and earlier" lines wrap theme={null}
    client.alias(user, previousUser);
    ```
  </CodeGroup>
</Accordion>

### Lua

In version 2.0 and newer of the Lua SDK, aliasing is no longer supported or required. To learn more, read [Lua (server-side) SDK 1.x to 2.0 migration guide](/docs/sdk/server-side/lua/migration-1-to-2).

<Accordion title="Expand Lua code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```lua title="Lua SDK v1.x" lines wrap theme={null}
    client:alias(newUser, previousUser)
    ```
  </CodeGroup>
</Accordion>

### Node.js (server-side)

In version 7.0 and newer of the Node.js (server-side) SDK, aliasing is no longer supported or required. To learn more, read [Node.js (server-side) SDK 6.x to 7.0 migration guide](/docs/sdk/server-side/node-js/migration-6-to-7).

<Accordion title="Expand Node.js (server-side) code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```js title="JavaScript" lines wrap theme={null}
    client.alias(newUser, previousUser);
    ```
  </CodeGroup>
</Accordion>

### PHP

In version 5.0 and newer of the PHP SDK, aliasing is no longer supported or required. To learn more, read [PHP SDK 4.x to 5.0 migration guide](/docs/sdk/server-side/php/migration-4-to-5).

<Accordion title="Expand PHP code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```php title="PHP" lines wrap theme={null}
    $client->alias($user, $previousUser);
    ```
  </CodeGroup>
</Accordion>

### Python

In version 8 and newer of the Python SDK, aliasing is no longer supported or required. To learn more, read [Python SDK 7.x to 8.0 migration guide](/docs/sdk/server-side/python/migration-7-to-8).

<Accordion title="Expand Python code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```python title="Python SDK v7.x and earlier" lines wrap theme={null}
    ldclient.get().alias(new_user, previous_user)
    ```
  </CodeGroup>
</Accordion>

### Ruby

In version 7 and newer of the Ruby SDK, aliasing is no longer supported or required. To learn more, read [Ruby SDK 6.x to 7.0 migration guide](/docs/sdk/server-side/ruby/migration-6-to-7).

<Accordion title="Expand Ruby code sample for older versions">
  To manually send an `alias` event:

  <CodeGroup>
    ```ruby title="Ruby SDK v6.x and earlier" lines wrap theme={null}
    client.alias(new_user, previous_user)
    ```
  </CodeGroup>
</Accordion>

### Rust

In version 1 and newer of the Rust SDK, aliasing is not supported or required. To learn more, read [Rust SDK v1 implementation guide](/docs/sdk/server-side/rust/implementation-v1).

<Accordion title="Expand Rust code sample for the beta version">
  To manually send an `alias` event:

  <CodeGroup>
    ```rust title="Rust beta" lines wrap theme={null}
    client.alias(user, previous_user);
    ```
  </CodeGroup>
</Accordion>
