# setAttribute

Sets the value of an attribute in the registration.

## Syntax

```javascript
MCReactModule.setAttribute(key, value);
```

## Parameters

| Parameter | Type     | Description                                                     |
| --------- | -------- | --------------------------------------------------------------- |
| `key`     | `string` | The name of the attribute to be set in the registration.        |
| `value`   | `string` | The value of the `key` attribute to be set in the registration. |

## Returns

- `void` - No return value.

## Example

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

const setUserAttribute = () => {
  try {
    MCReactModule.setAttribute("userType", "premium");
    MCReactModule.setAttribute("lastLogin", new Date().toISOString());
    console.log("Attributes set successfully");
  } catch (error) {
    console.error("Error setting attribute:", error);
  }
};
```

## See Also

- [getAttributes() Method](/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/react_getAttributes.md)
- [clearAttribute() Method](/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/react_clearAttribute.md)
- [Android SDK Reference](https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/javadocs/SFMCSdk/8.0/-s-f-m-c%20-s-d-k/com.salesforce.marketingcloud.sfmcsdk.components.identity/-identity/set-profile-attribute.html)
- *SDK Reference for iOS*: [Identity Class](/docs/marketing/mobile-unified-sdk/references/engagement-mobile-sdk-reference/identity.md)
