Skip to main content

Clipboard

The clipboard module provides convenient wrappers around the web Clipboard API.

danger

This module should not be used for copying files, folders, or advanced data. Alternatively, use the fs module.

Usage

import { clipboard } from "/42/api/io/clipboard.js"

Copy

await clipboard.copy("Hello, world!")

With a notification toast:

await clipboard.copy("Hello, world!", {
notif: true,
})

Paste

const text = await clipboard.paste()

Parameters

copy(text, options)

ParameterTypeDescription
textStringText to copy
options.notifBoolean/String/FunctionShow a toast notification after copying

paste()

Returns a Promise<string> with the clipboard content.