npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@paulmojicatech/native-clipboard

v0.0.6

Published

Provides native copy and paste functionality for iOS and Android

Readme

@paulmojicatech/native-clipboard

Native context menu with copy, cut, paste, and select all functionality for iOS, Android, and Web.

Features

  • 📋 Direct Clipboard Access: Read from and write to the system clipboard
  • 🎯 Native Gesture Recognition: Leverages platform-native WebView capabilities
  • 🔄 Cross-App Support: Access clipboard content from any app on the device
  • 📝 Full Context Menu: Copy, Cut, Paste, and Select All actions
  • 🔔 Event Dispatching: Get notified when users perform clipboard actions
  • 🌐 Cross-Platform: Works on iOS, Android, and Web
  • Zero Configuration: Works across the entire app without element targeting
  • 🎨 Native UI: Uses platform-native context menus for consistent UX

Install

npm install @paulmojicatech/native-clipboard
npx cap sync

Quick Start

Direct Clipboard Access

import { NativeClipboard } from '@paulmojicatech/native-clipboard';

// Read from clipboard (works with text copied from any app)
const result = await NativeClipboard.read();
console.log('Clipboard:', result.value);

// Write to clipboard
await NativeClipboard.write({ string: 'Hello World!' });

Context Menu

import { NativeClipboard } from '@paulmojicatech/native-clipboard';

// Enable native context menu
await NativeClipboard.enableContextMenu({
  enableCopy: true,
  enablePaste: true,
  enableCut: true,
  enableSelectAll: true
});

// Listen for clipboard actions
NativeClipboard.addListener('clipboardMenuAction', (event) => {
  switch (event.action) {
    case 'copy':
      console.log('User copied:', event.selectedText);
      break;
    case 'paste':
      console.log('User pasted:', event.text);
      // Insert the pasted text into your active element
      break;
    case 'cut':
      console.log('User cut:', event.selectedText);
      // Remove selected text from your UI
      break;
    case 'selectAll':
      console.log('User selected all');
      break;
  }
});

For complete examples with React and Vue, see USAGE_EXAMPLE.md.

API

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>

| Param | Type | | ------------- | ------------------------------- | | options | { value: string; } |

Returns: Promise<{ value: string; }>


read()

read() => Promise<{ value: string; }>

Read text from the native clipboard

Returns: Promise<{ value: string; }>


write(...)

write(options: { string: string; }) => Promise<void>

Write text to the native clipboard

| Param | Type | | ------------- | -------------------------------- | | options | { string: string; } |


enableContextMenu(...)

enableContextMenu(options?: { enableCopy?: boolean | undefined; enablePaste?: boolean | undefined; enableCut?: boolean | undefined; enableSelectAll?: boolean | undefined; } | undefined) => Promise<void>

Enable native long press context menu for copy/paste This enables system-level gesture recognition on the WebView

| Param | Type | | ------------- | ------------------------------------------------------------------------------------------------------------- | | options | { enableCopy?: boolean; enablePaste?: boolean; enableCut?: boolean; enableSelectAll?: boolean; } |


disableContextMenu()

disableContextMenu() => Promise<void>

Disable native long press context menu


addListener('clipboardMenuAction', ...)

addListener(eventName: 'clipboardMenuAction', listenerFunc: (event: ClipboardMenuActionEvent) => void) => Promise<PluginListenerHandle>

Add a listener for clipboard context menu events

| Param | Type | | ------------------ | ------------------------------------------------------------------------------------------------- | | eventName | 'clipboardMenuAction' | | listenerFunc | (event: ClipboardMenuActionEvent) => void |

Returns: Promise<PluginListenerHandle>


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin


Interfaces

PluginListenerHandle

| Prop | Type | | ------------ | ----------------------------------------- | | remove | () => Promise<void> |

ClipboardMenuActionEvent

| Prop | Type | | ------------------ | ------------------------------------------------------ | | action | 'copy' | 'paste' | 'cut' | 'selectAll' | | text | string | | selectedText | string |

Use Cases

Reading Clipboard from Other Apps

// User copies text in another app (e.g., Notes, Messages, Browser)
// Then opens your app

const clipboardContent = await NativeClipboard.read();
console.log('Got text from other app:', clipboardContent.value);

// Use it in your app
document.getElementById('myInput').value = clipboardContent.value;

Sharing Data Between Apps

// Copy data to clipboard so user can paste in another app
await NativeClipboard.write({
  string: 'https://example.com/share/12345'
});

// Show confirmation
alert('Link copied! You can now paste it anywhere.');

How It Works

iOS

  • Uses UIPasteboard.general for direct clipboard access
  • Adds a UILongPressGestureRecognizer to the WebView's scroll view
  • Shows native iOS context menu using UIMenu (iOS 13+)
  • Integrates seamlessly with system clipboard

Android

  • Uses ClipboardManager for direct clipboard access
  • Overrides WebView's CustomSelectionActionModeCallback
  • Uses native Android ActionMode for context menu
  • Automatically handles text selection and clipboard operations

Web

  • Uses browser's Clipboard API for read/write operations
  • Intercepts contextmenu events (right-click)
  • Shows custom-styled menu using Clipboard API
  • Falls back to browser's default menu if disabled

Permissions

Android

No special permissions required. Clipboard access is automatic.

iOS

No special permissions required. Clipboard access is automatic.

Web

The Clipboard API requires:

  • HTTPS (or localhost for development)
  • User interaction (satisfied by user-initiated actions)