Developer

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()

ParameterTypeDescription
ReturnsPromise<string>The current clipboard text

Throws if no text is on the clipboard.

rp.clipboard.write(text)

ParameterTypeDescription
textstringThe text to copy to clipboard
ReturnsPromise<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:read and clipboard:write capabilities are separate — you can request only the one you need.