---
name: "setClipboardData"
mode: "kit"
versionRequirements:
  - { name: "BaseKit", version: "2.0.1" }
  - { name: "@ray-js/ray", version: "0.3.23" }
platform:
  - "iOS"
  - "Android"
async: true
---

## setClipboardData

> [VERSION] BaseKit >= 2.0.1 | @ray-js/ray >= 0.3.23

> [PLATFORM] iOS, Android

> ⚡ **Supports Promise** — Returns a Promise when success / fail / complete callbacks are omitted.

### Description

Set the system clipboard content

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `isSensitive` | `boolean` | No | `false` | `3.2.0` | Whether the content is sensitive true: yes; false: no; default is non-sensitive If sensitive, it can prevent sensitive content from appearing in any content preview shown in the clipboard copy visual confirmation on Android 13 and later Note: This property only applies to devices running Android 13 or later |
| `data` | `string` | Yes | - | `2.0.1` | Clipboard content |
| `complete` | `() => void` | No | - | - | Completion callback (executed on both success and failure) |
| `success` | `() => void` | No | - | - | Callback on successful API call |
| `fail` | `(params: Object) => void` ↓see below | No | - | - | Failure callback |

#### fail callback parameters

| Property | Type | Description |
| --- | --- | --- |
| `errorMsg` | `string` | Error message |
| `errorCode` | `string \| number` | Error code |
| `innerError` | `Object` | Error extension |

##### fail(params).innerError properties

| Property | Type | Description |
| --- | --- | --- |
| `errorCode` | `string \| number` | Error extension code |
| `errorMsg` | `string` | Error extension message |


### Examples

#### Demo

```tsx
import { setClipboardData } from '@ray-js/ray'

// Set system clipboard content (isSensitive marks whether the data is sensitive; effective on Android 13+ only)
setClipboardData({
  data: "Hello Tuya",
  isSensitive: false,
  success: () => console.log("Copied to clipboard"),
  fail: error => console.error(error),
});
```
