Skip to content

anIcedAntFA/ctc

Repository files navigation

📋 @ngockhoi96/ctc

Modular, tree-shakeable browser utilities monorepo. Core clipboard APIs plus idiomatic framework adapters for React, Vue, and Svelte. Zero runtime dependencies, SSR-safe, framework-agnostic.

npm version Bundle Size npm downloads React Vue Svelte TypeScript tree-shakeable Coverage CI Release License: MIT

Why ctc? Modern Clipboard API under the hood, SSR-safe out of the box, TypeScript-native with zero any, multi-framework adapters that share a zero-dependency core, and fully tree-shakeable. See full comparison →

All functions are SSR-safe -- safe to import in Next.js, Nuxt, or any server-side environment without crashing.

Packages

Package Description Install
@ngockhoi96/ctc Core clipboard utilities (copy, read, detect) pnpm add @ngockhoi96/ctc
@ngockhoi96/ctc-react React hook useCopyToClipboard pnpm add @ngockhoi96/ctc-react @ngockhoi96/ctc
@ngockhoi96/ctc-vue Vue 3 composable useCopyToClipboard pnpm add @ngockhoi96/ctc-vue @ngockhoi96/ctc
@ngockhoi96/ctc-svelte Svelte action + rune/store pnpm add @ngockhoi96/ctc-svelte @ngockhoi96/ctc

Quick Start

import { copyToClipboard, isClipboardSupported } from '@ngockhoi96/ctc/clipboard'

button.addEventListener('click', async () => {
  if (isClipboardSupported()) {
    const success = await copyToClipboard('Hello, world!')
    console.log(success ? 'Copied!' : 'Copy failed')
  }
})

For framework-idiomatic usage, see the React, Vue, or Svelte package README linked above. For the full API reference (all five functions, error codes, options), see packages/core/README.md.

Monorepo Structure

.
├── packages/
│   ├── core/      # @ngockhoi96/ctc — clipboard utilities
│   ├── react/     # @ngockhoi96/ctc-react — React hook
│   ├── vue/       # @ngockhoi96/ctc-vue — Vue composable
│   └── svelte/    # @ngockhoi96/ctc-svelte — action + rune
├── playground/    # standalone Vite apps per framework
└── .changeset/    # versioning + changelog config

Built with pnpm workspaces + Turborepo. See CONTRIBUTING.md for setup.

Browser Support

Function Chrome Firefox Safari HTTP Support
copyToClipboard 66+ 63+ 13.1+ No (use legacy)
readFromClipboard 66+ 63+ 13.1+ No
isClipboardSupported 66+ 63+ 13.1+ Returns false
isClipboardReadSupported 66+ 63+ 13.1+ Returns false
copyToClipboardLegacy All All Partial Yes

All functions require ES2020+ (>95% global browser support).

All functions are SSR-safe and will return false or null when called in a server-side environment (Node.js, Deno, Bun) without crashing.

Similar / Related Projects

The following libraries solve clipboard operations in similar or overlapping ways. Listed here for reference — see BENCHMARKS.md for a detailed comparison table.

Framework-agnostic

  • clipboard-copy — Minimal clipboard write utility using the modern Clipboard API with execCommand fallback. Last updated 2020.
  • copy-to-clipboard — Clipboard write utility with broad browser support via execCommand. Last updated 2022.

React

Vue

  • @vueuse/core useClipboard — Clipboard composable included in the VueUse collection of Vue 3 utilities. TypeScript-native.

Svelte

The Svelte clipboard ecosystem is sparse. The Svelte docs show how to write a clipboard action natively; no widely-maintained dedicated library exists as of 2026.

License

MIT

About

Modular, tree-shakeable browser utilities monorepo. Core clipboard APIs plus idiomatic framework adapters for React, Vue, and Svelte. Zero runtime dependencies, SSR-safe, framework-agnostic.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors