copifi
v1.0.1
Published
Shared clipboard for devices on the same WiFi — named rooms, code auth, LAN discovery, background sync.
Maintainers
Readme
copifi
Shared clipboard for devices on the same WiFi. A host starts a named room and gets a join code. Other devices discover rooms on the network and join with that code. Once joined, copying anything on any device shows up on all the others — automatically, in the background. Fully local: nothing leaves your network.
Runs over self-signed HTTPS so browsers allow clipboard access on other devices.
Install
Needs Node.js 18+ on every device that runs the CLI.
npm install -g copifiThat gives you the global copifi command. Verify with copifi help.
Certificates are stored in ~/.copifi/certs (a user-writable location), so the global install
works without permission issues.
Run from source instead
git clone https://github.com/entrepreter/copifi.git
cd copifi
npm install
npm link # global `copifi` command — or just use `node cli.js <command>`For maintainers — releasing updates
The package is published to npm as copifi and the
source lives at github.com/entrepreter/copifi. To ship
an update:
npm version patch # bump the version (patch | minor | major)
git push --follow-tags
npm publishTip:
npm pack --dry-runpreviews exactly which files get published.
The flow
1. On the host machine — start a room:
copifi host officeThis prints the room's join code (e.g. 4821), a QR code, and starts syncing the host's
own clipboard. Leave it running.
2. On another machine — see what's on the network:
copifi lsROOM HOST ADDRESS
office shivam-pc.local 192.168.1.42:30003. Join by name and enter the code:
copifi join office
Enter the room code: 4821That's it. Copy anything on any joined device and it lands on every other device in the room.
Phones (or anyone without the CLI) can join from a browser: open https://<host-ip>:3000, type
the code, and go.
Commands
| Command | What it does |
| --- | --- |
| copifi host <name> | Start the room's server and sync this device. Prints the join code. |
| copifi serve <name> | Start only the server (a hub; doesn't sync this device's clipboard). |
| copifi ls | List rooms available on this WiFi. |
| copifi join <name> | Find the room on the network and join it (prompts for the code). |
| copifi help | Show help. |
Flags: --code <code> (skip the prompt), --name <name> (device label), --port <n>,
--poll <ms>, --server <url> (join a URL directly, skipping discovery).
Levels of "automatic"
- CLI / native (
host,join) — true background sync. Copy anywhere, in any app, no window needed. This is the recommended way on laptops/desktops. - Browser — auto-syncs while the copifi tab is in front (the browser asks for clipboard permission once). A browser tab cannot read the clipboard while it's in the background — that's a security rule in every browser and OS, which is exactly why the native CLI helper exists.
Phones & an "Apple Universal Clipboard"-like experience
Apple's Universal Clipboard feels magical because it's built into the OS — the system watches the clipboard in the background and syncs via Handoff. Third-party apps cannot get that same background access on phones, so here's what's actually achievable per platform:
- Desktops (Windows / macOS / Linux): already Apple-like. The CLI helper (
host/join) reads and writes the OS clipboard in the background — copy anywhere, it appears everywhere. No window needed. - Android: a native app can approximate it by running a foreground service (with a persistent notification) to watch the clipboard. Android 10+ restricts background clipboard reads, so the notification/foreground-service is required — close but not invisible.
- iOS: Apple does not allow any third-party app to read the clipboard in the background; only the system's own Universal Clipboard can. The realistic iOS experience is: a Share-sheet extension ("Share → copifi") to push, and open/tap to paste. Not fully automatic — that's an Apple platform limit, not a design choice.
Today, with zero install, a phone joins via the browser: scan the QR the host prints (or open
https://<host-ip>:3000), enter the code, and it's in the room — receiving clips and sending with
Send/auto-send. The limit is that a phone browser only reads the clipboard while the tab is in the
foreground.
Recommended path to get as close as possible:
- Use the CLI on all laptops/desktops — that half is already seamless.
- For phones, use the browser client (optionally as a PWA "add to home screen"). Accept foreground-only clipboard.
- Only if you truly need hands-free phone sync, build a thin native app (React Native/Flutter) that talks to the same room server: a foreground service on Android, and a Share extension + in-app paste on iOS. The server/protocol here is already the backbone for that — no server changes needed, just native clients.
Cross-platform
Works on Windows, macOS, and Linux — same commands everywhere.
- Clipboard access needs no extra setup on Windows or macOS (built-in tools). On Linux,
install
xselorxclip. - First run of
host/servemay trigger a firewall prompt (Windows Defender / macOS) — allow it on private networks so other devices can connect, and so mDNS discovery works. - Discovery uses mDNS/Bonjour. If
lsshows nothing (some corporate/guest networks block multicast), join directly:copifi join <name> --server https://<host-ip>:3000.
The certificate warning (expected)
The cert is self-signed, so a browser shows a one-time warning on first connect — click
Advanced → Proceed. The CLI accepts the LAN cert automatically. Want warning-free certs?
Install mkcert, run mkcert -install and
mkcert <host-ip>, then drop key.pem/cert.pem into ./certs.
How it works
- Transport: WiFi/LAN only; the server binds
0.0.0.0. - Discovery: each host advertises
_clipshare._tcpvia mDNS;lsbrowses for it (discovery.js). - Auth: the room code is the shared secret — correct code = admitted (no manual approval).
- Realtime: a single WebSocket hub relays clips to all authenticated members. State is in memory.
- Clipboard: the native helper reads/writes the OS clipboard in the background; the browser uses
navigator.clipboardwhen focused. Echo protection stops received text from bouncing back.
Files
cli.js— thecopificommand (host / serve / ls / join).server.js— HTTPS + WebSocket hub for one named, code-authenticated room; mDNS advertising.helper.js— background OS-clipboard sync client.discovery.js— mDNS publish/browse.public/index.html— the browser client.
