Clipboard
Use the Clipboard APIs to work with text from your clipboard and current selection. You can write contents to the clipboard through Clipboard.copy and clear it through Clipboard.clear. The Clipboard.paste function inserts text at the current cursor position in your frontmost app.
The action Action.CopyToClipboard can be used to copy content of a selected list item to the clipboard and the action Action.Paste can be used to insert text at in your frontmost app.

API Reference

copy

Copies text to the clipboard.

Signature

1
async function copy(text: string): Promise<void>;
Copied!

Example

1
import { Clipboard } from "@raycast/api";
2
3
export default async () => {
4
await Clipboard.copy("https://raycast.com");
5
};
Copied!

Parameters

Name
Type
Required
Description
text
string
Yes
The text to copy to the clipboard.

Return

A Promise that resolves when the text is copied to the clipboard.

paste

Pastes text to the current selection of the frontmost application.

Signature

1
async function paste(text: string): Promise<void>;
Copied!

Example

1
import { Clipboard } from "@raycast/api";
2
3
export default async () => {
4
await Clipboard.paste("I really like Raycast's API");
5
};
Copied!

Parameters

Name
Type
Required
Description
text
string
Yes
The text to insert at the cursor.

Return

A Promise that resolves when the text is pasted.

clear

Clears the current clipboard contents.

Signature

1
async function clear(): Promise<void>;
Copied!

Example

1
import { Clipboard } from "@raycast/api";
2
3
export default async () => {
4
await Clipboard.clear();
5
};
Copied!

Return

A Promise that resolves when the clipboard is cleared.

readText

Reads the clipboard as plain text.

Signature

1
async function readText(): Promise<string | undefined>;
Copied!

Example

1
import { Clipboard } from "@raycast/api";
2
3
export default async () => {
4
const text = await Clipboard.readText();
5
console.log(text);
6
};
Copied!

Return

A promise that resolves when the clipboard content was read as plain text.
Copy link
Edit on GitHub