@tauri-apps/plugin-clipboard-manager
Read and write to the system clipboard.
Functions
Section titled “Functions”clear()
Section titled “clear()”function clear(): Promise<void>;Clears the clipboard.
Platform-specific
- Android: Only supported on SDK 28+. For older releases we write an empty string to the clipboard instead.
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”import { clear } from '@tauri-apps/plugin-clipboard-manager';await clear();2.0.0
readImage()
Section titled “readImage()”function readImage(): Promise<Image>;Gets the clipboard content as Uint8Array image.
Platform-specific
- Android / iOS: Not supported.
Returns
Section titled “Returns”Promise<Image>
A promise resolving to the clipboard contents as an Image.
Example
Section titled “Example”import { readImage } from '@tauri-apps/plugin-clipboard-manager';
const clipboardImage = await readImage();const blob = new Blob([await clipboardImage.rgba()], { type: 'image' })const url = URL.createObjectURL(blob)2.0.0
readText()
Section titled “readText()”function readText(): Promise<string>;Gets the clipboard content as plain text.
Returns
Section titled “Returns”Promise<string>
A promise resolving to the clipboard contents as plain text.
Example
Section titled “Example”import { readText } from '@tauri-apps/plugin-clipboard-manager';const clipboardText = await readText();2.0.0
writeHtml()
Section titled “writeHtml()”function writeHtml(html, altText?): Promise<void>;- Writes HTML or fallbacks to write provided plain text to the clipboard.
Platform-specific
- Android / iOS: Not supported.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
html |
string |
The HTML markup to write to the clipboard. |
altText? |
string |
The plain text fallback written alongside the HTML, used by targets that cannot render it. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { writeHtml } from '@tauri-apps/plugin-clipboard-manager';await writeHtml('<h1>Tauri is awesome!</h1>', 'plaintext');// The following will write "<h1>Tauri is awesome</h1>" as plain textawait writeHtml('<h1>Tauri is awesome!</h1>', '<h1>Tauri is awesome</h1>');// we can read html data only as a string so there's just readText(), no readHtml()assert(await readText(), '<h1>Tauri is awesome!</h1>');2.0.0
writeImage()
Section titled “writeImage()”function writeImage(image): Promise<void>;Writes image buffer to the clipboard.
Platform-specific
- Android / iOS: Not supported.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
image |
| string | Image | ArrayBuffer | Uint8Array<ArrayBufferLike> | number[] |
The image to write, as a path, raw RGBA bytes, or an existing Image. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { writeImage } from '@tauri-apps/plugin-clipboard-manager';const buffer = [ // A red pixel 255, 0, 0, 255,
// A green pixel 0, 255, 0, 255,];await writeImage(buffer);2.0.0
writeSecret()
Section titled “writeSecret()”function writeSecret(text): Promise<void>;Writes sensitive plain text, such as a password, to the clipboard.
The text is marked so the system doesn’t keep or share it: on Windows it is excluded from clipboard history and cloud sync, on macOS and Linux clipboard managers are asked to skip it, on Android it is flagged as sensitive so the clipboard preview hides it, and on iOS it is not synced to other devices.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text |
string |
The plain text to write to the clipboard. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { writeSecret } from '@tauri-apps/plugin-clipboard-manager';await writeSecret('my-password');2.5.0
writeText()
Section titled “writeText()”function writeText(text, opts?): Promise<void>;Writes plain text to the clipboard.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text |
string |
The plain text to write to the clipboard. |
opts? |
{ label?: string; } |
Additional configuration for the write operation. |
opts.label? |
string |
A label describing the copied content. Android only, ignored on other platforms. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';await writeText('Tauri is awesome!');assert(await readText(), 'Tauri is awesome!');2.0.0
© 2026 Tauri Contributors. CC-BY / MIT