API reference
Exports of @sigx/lynx-clipboard v0.28.0.
The package has a single named export: the frozen Clipboard object. There is no default export and no exported types or interfaces. Every method works on both iOS and Android.
import { Clipboard } from '@sigx/lynx-clipboard';
Objects
Clipboard
A singleton object providing system clipboard access — UIPasteboard on iOS, ClipboardManager on Android. It is frozen (as const); its methods are documented individually below.
const Clipboard: {
readonly setString: (text: string) => Promise<void>;
readonly getString: () => Promise<string>;
readonly hasString: () => Promise<boolean>;
readonly isAvailable: () => boolean;
};
Platform: iOS, Android.
Functions
Clipboard.setString
Writes a string to the system clipboard.
setString(text: string): Promise<void>
Parameters
text— the string to place on the clipboard. Pass''to clear it;nullorundefinedis coerced to an empty string natively.
Returns: a promise that resolves once the native write has completed, and rejects when the write fails with a SigxError (code: 'native_error', message [@sigx/lynx-clipboard] setString failed: …). Android's setPrimaryClip genuinely can fail — a clip over the binder transaction limit throws — so await the call wherever a silent no-op would be a bug.
Platform: iOS, Android. On Android the clip is labelled sigx-lynx-go.
Not provided
Two requests come up often enough to answer here:
- A URL slot. iOS has a dedicated
UIPasteboard.url; Android has no equivalent. Write the URL as text withsetString(url). - A clipboard change listener. iOS has no clipboard-change notification at all, and polling
getStringfires the "Pasted from …" toast on every read.
Clipboard.getString
Asynchronously reads the clipboard's current string.
getString(): Promise<string>
Returns: a promise resolving to the clipboard's string contents, or "" when the clipboard is empty. It never rejects on an empty clipboard.
Platform: iOS, Android. On iOS 14 and later, reading the clipboard triggers the system "Pasted from <App>" toast — call this only on explicit user intent, never on a poll.
Clipboard.hasString
Asynchronously reports whether the clipboard currently contains a string.
hasString(): Promise<boolean>
Returns: a promise resolving to true if the clipboard holds a string, false otherwise. Reports presence without exposing the contents.
Platform: iOS (UIPasteboard.hasStrings); Android (hasPrimaryClip plus a text/* MIME-type check).
Clipboard.isAvailable
Synchronously reports whether the native Clipboard module is linked into the current build.
isAvailable(): boolean
Returns: true if the native module is registered and callable, false if it has not been linked (run sigx prebuild and rebuild). Delegates to isModuleAvailable from @sigx/lynx-core.
Platform: iOS, Android.
