← Plugins / Clipboard
This small community plugin reads from and writes to the device's native clipboard. Use it to let users copy a code, link or token with one tap, or to paste content back into your app — the kind of polish people expect from a native experience.
cordova plugin add cordova-clipboard
The plugin is exposed as cordova.plugins.clipboard after deviceready:
| Method | Description |
|---|---|
copy(text, success, error) | Write a string to the clipboard. |
paste(success, error) | Read the current clipboard contents; success receives the text. |
clear(success, error) | Empty the clipboard (Android). |
Copy a referral code and confirm it landed on the clipboard:
function copyCode() {
cordova.plugins.clipboard.copy(
"DEDRIS-2026",
function () {
console.log("Copied to clipboard");
},
function () {
console.error("Copy failed");
}
);
}
function readClipboard() {
cordova.plugins.clipboard.paste(function (text) {
console.log("Clipboard: " + text);
});
}