# getDeviceId

Returns the `deviceId` used by Engagement to send push messages to the device.

## Syntax

```javascript
MCReactModule.getDeviceId() ⇒ Promise.<string?>
```

## Returns

- `Promise.<string?>` - A promise to the device ID.

## Example

```javascript
import { MCReactModule } from "react-native-marketingcloudsdk";

const getCurrentDeviceId = async () => {
  try {
    const deviceId = await MCReactModule.getDeviceId();
    if (deviceId) {
      console.log("Device ID:", deviceId);
    } else {
      console.log("No device ID available");
    }
  } catch (error) {
    console.error("Error getting device ID:", error);
  }
};
```

## See Also

- [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-device-id.html)
- *SDK Reference for iOS*: [MarketingCloudSDK Module](/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/marketingcloudsdk.md#deviceidentifier)
