---
schema_version: "1"
id: 5aad77d2ad739211f92e8b8060b1f285a6b9255b165f3a7563747ed3bfd76e23
title: getContactKey
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud-mobilepush/engagement_sdk/references/react/react_getContactKey.md
canonical_url: https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/react_getContactKey.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 9906362bfa9832353db3a04bdc7729b7f8fd247100bc45b0dfc966f9d5ee9d04
products:
  - Salesforce Engagement SDK
---
# getContactKey

Returns the contact key currently set on the device.

## Syntax

```javascript
MCReactModule.getContactKey() ⇒ Promise.<string?>
```

## Returns

- `Promise.<string?>` - A promise to the current contact key.

## Example

```javascript
import { MCReactModule } from "react-native-marketingcloudsdk";

const getCurrentContactKey = async () => {
  try {
    const contactKey = await MCReactModule.getContactKey();
    if (contactKey) {
      console.log("Current contact key:", contactKey);
    } else {
      console.log("No contact key set");
    }
  } catch (error) {
    console.error("Error getting contact key:", error);
  }
};
```

## See Also

- [setContactKey() Method](https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/react_setContactKey.md)
- [Android SDK Reference](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/MarketingCloudSdk/8.0/-marketing%20-cloud%20-s-d-k/com.salesforce.marketingcloud.registration/-registration-manager/get-contact-key.html)
- _SDK Reference for iOS_: [contactKey() Method](https://developer.salesforce.com/docs/marketing/mobile-unified-sdk/references/ios-sdk-v11/mce-sdk/classes/marketingcloudsdk.md#contactkey)
