Browse topics
Clipboard API
Read and write the system clipboard from your custom resource.
Clipboard API
The Clipboard API provides read and write access to the system clipboard (plain text).
Capabilities required: clipboard:read and/or clipboard:write
Frontend (iframe)
import { createResourceClient } from "@rightplace/sdk";
const rp = createResourceClient();
await rp.ready();
// Write text to clipboard
await rp.clipboard.write("Hello from my resource!");
// Read text from clipboard
const text = await rp.clipboard.read();
// -> "Hello from my resource!"
Backend (Node.js)
import { createResourceServer } from "@rightplace/sdk/server";
const server = createResourceServer({
methods: {
copyResult: async (params, { rp }) => {
await rp.clipboard.write(params.text);
return { ok: true };
},
pasteInput: async (_params, { rp }) => {
const text = await rp.clipboard.read();
return { text };
},
},
});
server.start();
API Reference
rp.clipboard.read()
| Parameter | Type | Description |
|---|---|---|
| Returns | Promise<string> | The current clipboard text |
Throws if no text is on the clipboard.
rp.clipboard.write(text)
| Parameter | Type | Description |
|---|---|---|
text | string | The text to copy to clipboard |
| Returns | Promise<void> |
Manifest Configuration
{
"capabilities": [
"clipboard:read",
"clipboard:write"
]
}
Notes
- Only plain text is supported. Images and files cannot be read or written through this API.
- The
clipboard:readandclipboard:writecapabilities are separate — you can request only the one you need.