docs / ctx.clipboard
api reference

ctx.clipboard

Copy and paste, the iPhone way. Pasting asks the person every time; copying from their tap just happens.

clipboard

Calls

src/index.ts
const text = await ctx.clipboard.read();   // asks every time → the text, or null
await ctx.clipboard.write('copied!');     // in their tap → copies at once → true

Both need clipboard in your manifest. Without it, or with the switch off in Fave1 settings, they reject with denied.

Pasting asks

Every read() puts a question in front of the person: Paste into <your app>? It’s Fave1’s own, so neither the page nor your app can answer it. They tap Paste and you get the text they copied; they tap Not now, press Esc or close your app and you get null — the same as an empty clipboard or a picture. Not an error: put the cursor in your field and let them paste by hand.

src/index.ts
pasteButton.onclick = async () => {
  const text = await ctx.clipboard.read();
  if (text) fill(text); else input.focus();
};

Call it from a Paste button, never at launch — the question should answer something they just did. Safari and Firefox may show their own small Paste bubble right after; that’s the browser, and it’s expected.

Copying from a tap

Inside the person’s tap — a Copy button — write(text) copies at once and resolves true. The tap was their yes. The browser counts a tap for a few seconds after it; later than that (a long timer, a slow network answer) it shows them what would replace their last copy and asks first — false if they say no.

So copy in the click handler, before any await that waits on the network. Copying needs no permission at all if you call navigator.clipboard.writeText() yourself inside the tap — ctx.clipboard.write is for when you’d rather not think about it.

The rule

Read only through ctx.clipboard.read(). What someone copied can be a password or a private message. An app that reads navigator.clipboard itself, or reads without a Paste button the person pressed, gets sent back in review.