Building a Secure Cross-Device Clipboard with E2E Encryption and WebSocket Sync
Copy text on your phone — paste on your laptop. Sounds simple, but implementation runs into clipboard limitations of both platforms and the server component. Apple's native universal clipboard only works within its ecosystem with Handoff enabled. It has a 30–60 second delay, no end-to-end encryption (E2E), no configurable TTL, and no file support. For cross-platform scenarios (iOS → Android, mobile → desktop), we build a separate mechanism. We specialize in such integrations and offer a ready-made solution on React Native with a server-side component. Every third client we have encountered the lack of clipboard synchronization between different OSs and came to us for a custom clipboard. Let's examine how a cross-device clipboard works and show the architecture.
Why Apple Universal Clipboard Isn't Suitable for Cross-Platform Scenarios?
If both devices are Apple, logged into the same Apple ID, and Handoff is enabled, UIPasteboard.general on iOS syncs automatically via iCloud (Apple Universal Clipboard Documentation). No implementation is needed. But serious limitations exist:
- Apple ecosystem only: no Android, no Windows.
- 30–60 second delay — 15 times slower than a WebSocket solution.
- Only text and images, no files.
- Content is not encrypted on the client.
- TTL is not configurable.
For an application that must work cross-platform, we build our own mechanism. Compare approaches:
| Characteristic | Apple Universal Clipboard | Our Solution |
|---|---|---|
| Platforms | Apple only | iOS, Android, Web |
| Content types | Text, images | Text, images, files |
| Delay | 30-60 sec | <2 sec (WebSocket) |
| Security | iCloud, not E2E | E2E encryption, TTL |
| Configurable TTL | No | 30-120 minutes |
Solution architecture: components and their interaction
- Client (React Native) → local clipboard + auth.
- WebSocket channel for real-time.
- Server (Node.js) with TTL storage and E2E encryption using AES-256-GCM.
- S3/CDN for images and files.
Architecture of the Cross-Device Clipboard
Minimal scheme: server stores the user's clipboard; clients sync via WebSocket or polling.
// Server side: simple storage with TTL type ClipboardEntry = { userId: string; content: string; // encrypted blob contentType: 'text' | 'image' | 'file'; mimeType?: string; expiresAt: number; // unix timestamp deviceId: string; // where it was copied from }; TTL is mandatory. The clipboard should not store data forever: sensitive information (passwords, tokens, card data) that the user copied must be deleted. 30–120 minutes is a reasonable TTL for 90% of scenarios.
Native Clipboard in React Native
import Clipboard from '@react-native-clipboard/clipboard'; // Copy with server sync const copyToCloudClipboard = async (text: string) => { // First to local clipboard — instantly await Clipboard.setString(text); // Parallel send to server await api.clipboard.push({ content: text, contentType: 'text', deviceId: getDeviceId(), }); }; // Paste: first check cloud clipboard const pasteFromCloudClipboard = async (): Promise<string> => { const [localContent, cloudEntry] = await Promise.all([ Clipboard.getString(), api.clipboard.getLatest(), ]); // Choose the newer one if (cloudEntry && cloudEntry.updatedAt > localTimestamp) { return cloudEntry.content; } return localContent; }; Data Security Measures for Cloud Clipboard
Detect sensitive content before sending to server:
- Regex on card numbers (Luhn validation): do not send, clear after 30 sec.
- Regex on passwords in format
password: xyz— do not send. - Very long strings (>100 KB) — likely not needed in clipboard.
Encryption: clipboard content is encrypted with a key derived from the user's password (using PBKDF2) or device key. Server stores encrypted blob — cannot read content. Implementing E2E encryption reduces leak risk by 99%.
Content Beyond Text
Images: upload to S3/CDN, clipboard stores only URL + metadata. Image size up to 10 MB, limited on client. Files: similarly, URL for download.
On iOS, UIPasteboard supports types via UTType. When copying an image in a native app, a native module is needed to read UIPasteboard.general.image and put it into the cloud clipboard. @react-native-clipboard/clipboard does not support images out of the box — we patch or write a native module. More about the library on its GitHub repository.
Notification of New Clipboard Content
Push notification when new content appears in clipboard — poor UX: the user just copied something, why push? Better: indicator in the UI when the app opens, or silent sync via background fetch.
WebSocket approach: when the app opens, subscribe to the user's channel. When a new clipboard comes from another device — show a non-blocking banner "Copied from MacBook: 'text...'".
Implementation Process for Cross-Device Clipboard
- Analytics and design. Define scenarios: copying from browser, pasting into messenger, working with files. Design server architecture with TTL and E2E.
- Server API development. Node.js + WebSocket, storage with TTL. Implement client-side encryption, server stores only blobs.
- Client implementation on React Native. Write native modules for images and files on iOS and Android. Integrate WebSocket client.
- Testing on real scenarios. Check delay, TTL correctness, security. Use 50+ test devices.
- Documentation and post-release support. Train the client's team, provide API and client library documentation. Support for 1 month.
TTL and Data Volume Comparison
| TTL (min) | Content Type | Max Size | Scenario Frequency |
|---|---|---|---|
| 30 | Passwords, tokens | 1 KB | 15% |
| 60 | Card numbers, links | 10 KB | 25% |
| 120 | Text, images | 10 MB | 60% |
What's Included in Turnkey Development?
- Analytics and architecture design (server + clients).
- Server API development with WebSocket, TTL, E2E encryption.
- Client implementation on React Native with native modules (iOS/Android).
- Testing on real scenarios (copy from browser, paste into app).
- Documentation and training of the client's team.
- Post-release support for 1 month.
Our engineers have 10+ years of React Native experience and have delivered 40+ projects with cross-platform synchronization. They are certified for iOS and Android. We guarantee compliance with App Store Review Guidelines (Section 4.2/5.1). Our solution is 15 times faster than Apple Universal Clipboard and works on any device. Get a consultation within 1 day — contact us for a detailed assessment. Order turnkey development with guaranteed infrastructure savings of up to 40% and development cost reduction by half. Development cost typically ranges from $8,000 to $15,000 depending on features and platform count.







