React Native · APIs and utilities
Clipboard
Clipboard.
3 exports
Import
Clipboard
moduleClipboard.
| Name | Type | Description |
|---|---|---|
getString | () => Promise<string> | Text on the clipboard ("" if none). iOS 16+ may ask the user for permission on the first read; Android 12+ shows a "pasted" notice. |
hasString | () => Promise<boolean> | Is there text on the clipboard (without reading; asks no permission, shows no notice). |
setString | (text: string, options?: ClipboardSetOptions) => Promise<void> | Copies text to the clipboard. |
clear | () => Promise<void> | Empties the clipboard. |
addChangeListener | (listener: (event: { hasString: boolean; }) => void) => () => void | Called when the clipboard changes (while the app is in the foreground; on iOS things copied in the background are reported when the app comes to the foreground). Returns a function that ends the subscription. |
useClipboardHasString
functionTracks whether there is text on the clipboard (to enable/disable a paste button). Does not read the content.
ClipboardSetOptions
interfaceOptions for Clipboard.setString.
| Name | Type | Default | Description |
|---|---|---|---|
sensitive? | boolean | false | Sensitive data (password, code): hidden in the Android 13+ preview notification, and on iOS it does not go to other devices via Universal Clipboard. |
expiresIn? | number | Removed from the clipboard after this many ms (if the user did not copy something else). | |
label? | string | Android: the clip label (accessibility and preview). |