Command palette

@yasinsensoy/native

React Native · APIs and utilities

Clipboard

Clipboard.

3 exports

Import

import { Clipboard, useClipboardHasString } from "@yasinsensoy/native";

Clipboard

module

Clipboard.

NameTypeDescription
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) => () => voidCalled 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.

Tracks whether there is text on the clipboard (to enable/disable a paste button). Does not read the content.

useClipboardHasString(): boolean

Options for Clipboard.setString.

NameTypeDefaultDescription
sensitive?booleanfalseSensitive data (password, code): hidden in the Android 13+ preview notification, and on iOS it does not go to other devices via Universal Clipboard.
expiresIn?numberRemoved from the clipboard after this many ms (if the user did not copy something else).
label?stringAndroid: the clip label (accessibility and preview).