Clipboard

Use clipboard to copy and paste content between pages or apps

The Clipboard API enables copy and pasting to/from the clipboard. On iOS this API also allows copying images and URLs.

Clipboard function is implemented using Capacitor's default Clipboard API

import { Plugins } from '@capacitor/core';

const { Clipboard } = Plugins;

Clipboard.write({
  string: "Hello, Moto"
});

let str = await Clipboard.read({
  type: "string"
});
console.log('Got string from clipboard:', str.value);

Features

Using Clipboard page functions, you can

  • Copy text written in a read-only format (e.g. a key or password)

  • Copy text written in an editable text-box (e.g. something you have entered as a user)

  • Paste text using a button OR paste using long-press action of the device

Methods

It has three methods

  • read() - Reads the data from Clipboard

  • write() - Writes selected data to Clipboard

  • addListener() - Listens to Read or Write event from Clipboard

Last updated