@wefterjs/clipboard
v0.0.1
Published
Official Wefter plugin for reading and writing to the native system clipboard on Android (`ClipboardManager`) and iOS (`UIPasteboard`).
Readme
@wefterjs/clipboard
Official Wefter plugin for reading and writing to the native system clipboard on Android (ClipboardManager) and iOS (UIPasteboard).
Features
- 📋 System Clipboard Access: Read and write plain text or URLs to/from system clipboard.
- ⚡ Stateless & Cross-Platform: Native Android (
ClipboardManager) and iOS (UIPasteboard) implementations. - 🧹 Clipboard Management: Clear clipboard buffer programmatically with
clear().
Installation & Setup
- Add the plugin to your Wefter project:
wefter add @wefterjs/clipboard- Synchronize native projects:
wefter syncJavaScript / TypeScript API Reference
import { Clipboard } from "@wefterjs/clipboard";1. write(options)
Writes text or URL to the native clipboard.
interface ClipboardWriteOptions {
string?: string; // Text content to copy
url?: string; // URL content to copy
label?: string; // Clip label (Android only, optional)
}
await Clipboard.write({
string: "Hello from Wefter!",
});2. read()
Reads the current text or URL stored in the system clipboard.
interface ClipboardReadResult {
value: string; // The copied content or "" if empty
type: "string" | "url" | "empty";
string?: string;
url?: string;
}
const result = await Clipboard.read();
console.log("Clipboard content:", result.value, "Type:", result.type);3. clear()
Clears the primary system clipboard.
await Clipboard.clear();Complete Usage Example
import { Clipboard } from "@wefterjs/clipboard";
// Copy link
await Clipboard.write({ url: "https://wefter.dev" });
// Read link back
const clip = await Clipboard.read();
if (clip.type === "url") {
console.log("Copied URL:", clip.url);
}
// Clear clipboard
await Clipboard.clear();