@capawesome/capacitor-clipboard

中文文档
0.1.2发布于 2026/09/02MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3663

Capacitor plugin to read from and write to the system clipboard on Android, iOS, and Web.

原始使用文档
文档目录34 节
  1. Features
  2. Use Cases
  3. Compatibility
  4. Installation
  5. Android
  6. iOS
  7. Configuration
  8. Usage
  9. Write text to the clipboard
  10. Write HTML with a plain-text fallback
  11. Write an image to the clipboard
  12. Write a URL to the clipboard
  13. Read the clipboard content
  14. API
  15. read()
  16. write(...)
  17. Interfaces
  18. Enums
  19. Platform Behavior
  20. Android
  21. iOS
  22. Migrating from @capacitor/clipboard
  23. FAQ
  24. How is this plugin different from other similar plugins?
  25. Why is a notification shown when my app reads the clipboard?
  26. Why does reading the clipboard fail on Android?
  27. Can I write multiple content types at once?
  28. How are images handled by this plugin?
  29. How is this plugin different from the official @capacitor/c…
  30. Can I use this plugin with Ionic, React, Vue or Angular?
  31. Related Plugins
  32. Newsletter
  33. Changelog
  34. License

Capacitor Clipboard Plugin

Capacitor plugin to read from and write to the system clipboard.

Features

  • 📋 Read & Write: Read from and write to the system clipboard.
  • 🖼️ Images: Copy and paste real images, not just data URLs as plain text.
  • 📝 Rich Text: Write HTML content with a plain-text fallback.
  • 🔗 URLs: Copy URLs as native URL clipboard items.
  • 🌐 Cross-platform: Works on Android, iOS, and the web.
  • 🔒 App Store safe: Uses only official platform APIs.
  • 🤝 Compatibility: Works alongside the Share Target and Text Interaction plugins.
  • 📦 CocoaPods & SPM: Supports CocoaPods and Swift Package Manager for iOS.
  • 🔁 Up-to-date: Always supports the latest Capacitor version.

Missing a feature? Just open an issue and we'll take a look!

Use Cases

The Clipboard plugin is typically used whenever an app lets users copy or paste content, for example:

  • Copy to clipboard buttons: Let users copy coupon codes, invite links, or wallet addresses with one tap.
  • Paste support: Read text, URLs, or images from the clipboard into your app, for example into a form or editor.
  • Sharing images: Copy a generated image (such as a QR code or chart) so users can paste it into other apps.
  • Rich text workflows: Copy formatted HTML content with a plain-text fallback for apps that cannot handle HTML.

Compatibility

Plugin VersionCapacitor VersionStatus
0.x.x>=8.x.xActive support

Installation

You can use our AI-Assisted Setup to install the plugin. Add the Capawesome Skills to your AI tool using the following command:

npx skills add capawesome-team/skills --skill capacitor-plugins

Then use the following prompt:

 Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-clipboard` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capawesome/capacitor-clipboard
npx cap sync

Android

No additional configuration is required for this plugin.

iOS

No additional configuration is required for this plugin.

Configuration

No configuration required for this plugin.

Usage

The following examples show how to write text, HTML, images, and URLs to the clipboard, and how to read its current content.

Write text to the clipboard

Copy plain text to the system clipboard:

import { Clipboard } from '@capawesome/capacitor-clipboard';

const writeText = async () => {
  await Clipboard.write({ text: 'Hello World' });
};

Write HTML with a plain-text fallback

Copy HTML content and combine it with text to provide a plain-text fallback for apps that cannot handle HTML content:

import { Clipboard } from '@capawesome/capacitor-clipboard';

const writeHtml = async () => {
  await Clipboard.write({
    html: '<b>Hello World</b>',
    text: 'Hello World',
  });
};

Write an image to the clipboard

Copy a real image (not just a data URL as plain text) by passing a Base64-encoded data URL:

import { Clipboard } from '@capawesome/capacitor-clipboard';

const writeImage = async () => {
  await Clipboard.write({
    image: 'data:image/png;base64,iVBORw0KGgo...',
  });
};

Write a URL to the clipboard

Copy a URL as a native URL clipboard item:

import { Clipboard } from '@capawesome/capacitor-clipboard';

const writeUrl = async () => {
  await Clipboard.write({ url: 'https://capawesome.io' });
};

Read the clipboard content

Read the current content of the system clipboard. The result contains the content type (text, HTML, image, or URL) and the value. Note that on Android, reading the clipboard is only possible while the app is in the foreground, and on iOS, a system paste notification is displayed:

import { Clipboard } from '@capawesome/capacitor-clipboard';

const read = async () => {
  const { type, value } = await Clipboard.read();
  console.log('Type:', type, 'Value:', value);
};

API

read()

read() => Promise<ReadResult>

Read the current content of the system clipboard.

On Android, reading the clipboard is only possible while the app is in the foreground.

On iOS, reading the clipboard displays a system paste notification. This is expected behavior and cannot be suppressed.

Returns: Promise<ReadResult>

Since: 0.1.0


write(...)

write(options: WriteOptions) => Promise<void>

Write content to the system clipboard.

Exactly one of text, html, image or url must be provided. The html property may additionally be combined with text to provide a plain-text fallback.

ParamType
optionsWriteOptions

Since: 0.1.0


Interfaces

ReadResult

PropTypeDescriptionSince
typeClipboardContentTypeThe type of the content that was read from the clipboard.0.1.0
valuestringThe content that was read from the clipboard. Images are returned as a Base64-encoded data URL.0.1.0

WriteOptions

PropTypeDescriptionSince
htmlstringThe HTML content to write to the clipboard. Combine this with text to provide a plain-text fallback for apps that cannot handle HTML content.0.1.0
imagestringThe image to write to the clipboard as a Base64-encoded data URL.0.1.0
labelstringThe label used to describe the clipboard content. Only available on Android.0.1.0
textstringThe plain text to write to the clipboard.0.1.0
urlstringThe URL to write to the clipboard.0.1.0

Enums

ClipboardContentType

MembersValueDescriptionSince
Html'HTML'The content is HTML.0.1.0
Image'IMAGE'The content is an image, returned as a Base64-encoded data URL.0.1.0
Text'TEXT'The content is plain text.0.1.0
Url'URL'The content is a URL.0.1.0

Platform Behavior

Android

  • On Android 10 (API level 29) and later, apps can only read the clipboard while they are in the foreground and have input focus. The read(...) method rejects otherwise.
  • On Android 12 (API level 31) and later, the system shows a toast message when an app reads the clipboard content that was written by another app. This is expected behavior and cannot be suppressed.

iOS

  • On iOS 14 and later, the system shows a paste notification banner every time the clipboard is read. This is expected behavior and cannot be suppressed.

Migrating from @capacitor/clipboard

This plugin is a drop-in alternative to the official @capacitor/clipboard plugin with real image support on Android and HTML support on all platforms. The following differences apply:

@capacitor/clipboard@capawesome/capacitor-clipboard
write({ string: 'Hello' })write({ text: 'Hello' })
write({ image: dataUrl }) (text-only on Android)write({ image: dataUrl }) (real image on all platforms)
—write({ html: '<b>Hello</b>', text: 'Hello' })
read() → { value, type: 'text/plain' }read() → { value, type: 'TEXT' }

FAQ

How is this plugin different from other similar plugins?

It supports far more than plain text — copy and paste images, HTML with a plain-text fallback, and native URL items, with reliable real image handling on Android, iOS, and the web. The API is fully typed and actively maintained against the latest OS and framework versions, and it uses only official platform APIs so it stays safe for App Store and Google Play submissions. If you only ever copy plain text, a simpler setup is perfectly fine; if you need rich content and consistent behavior across every platform, this plugin is designed for exactly that.

Why is a notification shown when my app reads the clipboard?

On iOS 14 and later, the system shows a paste notification banner every time the clipboard is read. On Android 12 (API level 31) and later, the system shows a toast message when an app reads clipboard content that was written by another app. Both are expected platform behavior and cannot be suppressed.

Why does reading the clipboard fail on Android?

On Android 10 (API level 29) and later, apps can only read the clipboard while they are in the foreground and have input focus. The read() method rejects otherwise, so make sure to only call it in response to a user interaction while the app is visible.

Can I write multiple content types at once?

No, exactly one of text, html, image or url must be provided when calling write(...). The only exception is that html may additionally be combined with text to provide a plain-text fallback for apps that cannot handle HTML content.

How are images handled by this plugin?

Images are written to the clipboard as real images, not just data URLs as plain text, by passing a Base64-encoded data URL to write(...). When reading, images are also returned as a Base64-encoded data URL. See the usage examples above.

How is this plugin different from the official @capacitor/clipboard plugin?

This plugin is a drop-in alternative to the official @capacitor/clipboard plugin with real image support on Android and HTML support on all platforms. Only a few method options differ, see the migration table above.

Can I use this plugin with Ionic, React, Vue or Angular?

Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.

  • Share Target: Receive content such as text, links, and files from other apps.
  • Text Interaction: Enable and disable text interaction (selection, magnifier, callout menu) in the app's WebView.

Newsletter

Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our Capawesome Newsletter.

Changelog

See CHANGELOG.md.

License

See LICENSE.

版本与发布记录

@capawesome/capacitor-clipboard 共发布 4 个版本,首次发布于 2026/07/07;过去 12 个月发布了 4 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.2latest2026/09/022 个月前
0.1.12026/07/153 个月前
0.1.02026/07/143 个月前
0.0.12026/07/074 个月前

关于 @capawesome/capacitor-clipboard 的常见问题

@capawesome/capacitor-clipboard 是什么?

Capacitor plugin to read from and write to the system clipboard on Android, iOS, and Web.

如何安装 @capawesome/capacitor-clipboard?

在项目目录运行 npm install @capawesome/capacitor-clipboard,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capawesome/capacitor-clipboard 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capawesome/capacitor-clipboard 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capawesome/capacitor-clipboard 可以商用吗?

@capawesome/capacitor-clipboard 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@capawesome/capacitor-clipboard 的下载量有多少?

根据 npm 官方下载统计,@capawesome/capacitor-clipboard 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,663 次,日均约 122 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capawesome/capacitor-clipboard 还在维护吗?

最新版本 0.1.2 发布于 2026/09/02(2 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 4 个;首次发布于 2026/07/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。