Copy a string or serializable value to the system clipboard safely.
await copy(value);
import { copy } from 'kitzo/fns'; async function copyExample() { try { await copy('Hello, world!'); console.log('Copied successfully!'); } catch (err) { console.error('Copy failed:', err); } } copyExample();
| Parameter | Type | Description |
|---|---|---|
doc | string | The value to copy. Strings and numbers are used as-is; objects are JSON-stringified. |
Returns a Promise that resolves after the text is copied to the clipboard.
<textarea /> copy method if `navigator.clipboard` is unavailable.JSON.stringify.