webdev-power-kit
Version:
A powerful toolkit that simplifies access to browser features like clipboard, notifications, battery, vibration, and more — perfect for modern web developers.
16 lines (15 loc) • 429 B
JavaScript
/**
* Copies a given string to the clipboard.
* @param text - The text to copy
* @returns A Promise that resolves when the copy is complete
*/
export function copyToClipboard(text) {
return navigator.clipboard.writeText(text);
}
/**
* Reads the current string from the clipboard.
* @returns A Promise that resolves to clipboard content
*/
export function readClipboard() {
return navigator.clipboard.readText();
}