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 🙏

© 2026 – Pkg Stats / Ryan Hefner

clipwatch

v1.0.1

Published

A TypeScript utility library to monitor clipboard changes

Readme

📋 Clipwatch

Clipwatch Logo TypeScript License npm

🚀 A powerful TypeScript utility library to monitor clipboard changes in real-time!

InstallationFeaturesQuick StartAPI DocsExamples


🌟 Overview

Clipwatch is your go-to TypeScript library for clipboard monitoring! 🎯 Whether you're building a clipboard manager, password detector, or any app that needs clipboard awareness, Clipwatch has got you covered with its robust and easy-to-use API.


✨ Features

  • 🔄 Real-time Monitoring - Watch clipboard changes as they happen
  • 🚫 Smart Duplicate Prevention - No consecutive duplicate entries
  • 🕵️ Private Mode - Monitor without saving history
  • Dynamic Polling - Adjust monitoring speed on-the-fly
  • 📚 History Management - Full control over clipboard history
  • 🎯 Pattern Matching - React to specific clipboard content with regex
  • 💾 Import/Export - Save and restore clipboard history
  • 🔒 Secure - Works only in secure contexts

📦 Installation

Get started in seconds with npm:

npm install clipwatch

Or with yarn:

yarn add clipwatch

🚀 Quick Start

import { startWatching, onClipboardChange } from 'clipwatch';

// Start monitoring - it's that simple! 🎉
startWatching();

// React to clipboard changes
onClipboardChange((text) => {
  console.log(`📋 New clipboard content: ${text}`);
});

📖 API Documentation

🔍 Clipboard Monitoring

startWatching(options?)

🟢 Starts monitoring the clipboard for changes

startWatching({ 
  interval: 500,    // Check every 500ms ⚡
  private: true     // Don't save history 🕵️
});

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | interval | number | 1000 | Polling interval in milliseconds | | private | boolean | false | Enable private mode |


stopWatching()

🔴 Stops clipboard monitoring

stopWatching(); // Pause monitoring 🛑

setThrottle(ms)

⚙️ Dynamically adjust monitoring speed

setThrottle(2000); // Now checking every 2 seconds 🐢

getCurrentClipboard()

📋 Get current clipboard content

const text = await getCurrentClipboard();
console.log(`Current: ${text}`); // 📝

📚 History Management

getClipboardHistory()

📜 Retrieve all clipboard history

const history = getClipboardHistory();
// Returns: ['Text 1', 'Text 2', ...] 📚

addToHistory(text)

Manually add to history

addToHistory('Custom entry'); // ✍️

clearClipboardHistory()

🗑️ Clear all history

clearClipboardHistory(); // Fresh start! 🌟

exportClipboardHistory()

💾 Export history as JSON

const backup = exportClipboardHistory();
// Save to file, database, etc. 📦

importClipboardHistory(json)

📥 Import history from JSON

importClipboardHistory(savedHistory); // Restore! 🔄

🎯 Event Handling

onClipboardChange(callback)

👂 Listen for any clipboard change

onClipboardChange((text) => {
  console.log(`✨ Changed to: ${text}`);
});

onClipboardMatch(pattern, callback)

🎯 React to specific patterns

// Detect URLs 🌐
onClipboardMatch(/https?:\/\/\S+/i, (url) => {
  console.log(`🔗 URL detected: ${url}`);
});

// Detect emails 📧
onClipboardMatch(/\S+@\S+\.\S+/, (email) => {
  console.log(`📧 Email found: ${email}`);
});

// Detect passwords 🔐
onClipboardMatch(/password:\s*(\S+)/i, (match) => {
  console.log(`🚨 Password detected!`);
});

💡 Examples

🎨 Complete Example

import { 
  startWatching, 
  stopWatching, 
  onClipboardChange, 
  onClipboardMatch,
  getClipboardHistory,
  exportClipboardHistory 
} from 'clipwatch';

// 🚀 Start monitoring with custom settings
startWatching({ 
  interval: 500,
  private: false 
});

// 📢 Log all changes
onClipboardChange((text) => {
  console.log(`📋 Clipboard: ${text}`);
});

// 🔗 Detect and process URLs
onClipboardMatch(/https?:\/\/\S+/i, async (url) => {
  console.log(`🌐 Opening URL: ${url}`);
  // Could open in browser, validate, etc.
});

// 📧 Email detection
onClipboardMatch(/\S+@\S+\.\S+/, (email) => {
  console.log(`📮 Email copied: ${email}`);
});

// 💾 Save history before closing
window.addEventListener('beforeunload', () => {
  const history = exportClipboardHistory();
  localStorage.setItem('clipboardHistory', history);
  stopWatching(); // Clean up 🧹
});

🛡️ Privacy-Focused Usage

// Monitor without saving history
startWatching({ private: true });

onClipboardChange((text) => {
  // Process sensitive data without storing
  if (text.includes('password')) {
    console.log('🔐 Sensitive data detected!');
  }
});

⚙️ Requirements

  • 🌐 Browser Environment with navigator.clipboard API
  • 🔒 Secure Context (HTTPS or localhost)
  • 🎯 TypeScript 4.0+ (for development)

⚠️ Limitations

  • 🌍 Browser Support: Modern browsers only (Chrome 66+, Firefox 63+, Safari 13.1+)
  • 🔐 Permissions: User must grant clipboard access
  • 📱 Mobile: Limited support on mobile browsers

🤝 Contributing

We love contributions! 💖 Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch (git checkout -b feature/amazing-feature)
  3. 💻 Make your changes
  4. ✅ Run tests (npm test)
  5. 📝 Commit (git commit -m 'Add amazing feature')
  6. 🚀 Push (git push origin feature/amazing-feature)
  7. 🎉 Open a Pull Request

Check out our Contributing Guide for more details!


📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 Persianwolf404

Permission is hereby granted, free of charge...

👨‍💻 Author

Created with ❤️ by Persianwolf404


🏷️ Keywords

clipboardclipboard-monitorclipboard-managertypescriptclipboard-historyclipboard-watcherclipboard-apiregex-matcherevent-emitterbrowser-apiutility-libraryopen-source


⭐ Star us on GitHub!

If you find Clipwatch useful, please consider giving it a star! It helps others discover the project.

Star on GitHub