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

Clipboard.copy

Copies text to the clipboard.

Signature

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

Example

import { Clipboard } from "@raycast/api";
export default async () => {
await Clipboard.copy("https://raycast.com");
};

Parameters

Name
Description
Type
text*
The text to copy to the clipboard.
string

Return

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

Clipboard.paste

Pastes text to the current selection of the frontmost application.

Signature

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

Example

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

Parameters

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

Return

A Promise that resolves when the text is pasted.

Clipboard.clear

Clears the current clipboard contents.

Signature

async function clear(): Promise<void>;

Example

import { Clipboard } from "@raycast/api";
export default async () => {
await Clipboard.clear();
};

Return

A Promise that resolves when the clipboard is cleared.

Clipboard.readText

Reads the clipboard as plain text.

Signature

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

Example

import { Clipboard } from "@raycast/api";
export default async () => {
const text = await Clipboard.readText();
console.log(text);
};

Return

A promise that resolves when the clipboard content was read as plain text.