Share2Me

Back to Articles
Guide

The Complete Browser File Transfer Guide: How WebRTC Replaces Cloud Uploads

K

Kamal Tripathi

Founder & Lead Engineer, Share2Me

GuideJune 18, 202610 min read

Modern browsers have evolved far beyond document viewers. With APIs like WebRTC, Web Crypto, File System Access, and SharedArrayBuffer, the browser is now capable of serving as a complete real-time communication and data transfer platform. This guide explains how browser-native file transfer works technically, why it outperforms cloud-mediated uploads for many use cases, and how developers can leverage the same APIs to build their own browser-to-browser data pipelines — without a cloud storage backend.

1. The Browser as a Network Transport

For most of the web's history, the browser was a document renderer with limited networking capability. It could make HTTP requests to servers and receive HTML, CSS, JavaScript, and media responses. Peer-to-peer networking — where two browser instances talk to each other directly — was considered the domain of native applications and required plugins like Flash or Java applets. WebRTC changed this fundamentally. Introduced in Chrome 23 in 2012 and standardised by W3C in 2021, WebRTC gives browsers direct UDP socket-level access to the network, the ability to punch through NAT firewalls using STUN/TURN, and a full-stack protocol suite for secure peer-to-peer communication. The RTCDataChannel API built on top of WebRTC provides a bidirectional binary channel between two browsers with SCTP-level reliability guarantees — the same reliability model used for file delivery. For file transfer, the browser is no longer a client talking to a server. It is a peer, capable of establishing a direct data connection to any other WebRTC-enabled browser anywhere in the world.

  • WebRTC: Standardised in 2021 by W3C — available in Chrome 23+, Firefox 22+, Safari 11+, Edge 79+.
  • UDP Access: WebRTC gives browsers direct UDP socket access, enabling low-latency real-time communication.
  • NAT Traversal: ICE/STUN/TURN protocols allow browsers to find and connect to each other through home and corporate routers.
  • RTCDataChannel: Provides reliable, ordered binary transport via SCTP — the foundation for browser-native file transfer.

2. Reading and Streaming Files with the File System Access API

The File System Access API (available in Chromium browsers as of version 86) allows web applications to request read and write access to files on the user's local filesystem with an explicit permission dialog. This is more efficient than the older FileReader API because it supports streaming — you can read a 100 GB file chunk-by-chunk without loading the entire file into memory. For file transfer, the workflow is: the user grants permission to read a file via a file picker dialog; the application requests a FileSystemFileHandle; calls handle.getFile() to get a File object; then slices it into ArrayBuffer chunks using file.slice(offset, offset + CHUNK_SIZE).arrayBuffer(). Each chunk is encrypted using the Web Crypto API and sent via the RTCDataChannel. The receiving browser reassembles chunks in order and uses the File System Access API's write interface to stream chunks directly to disk, avoiding the need to buffer the entire received file in browser memory.

  • FileSystemFileHandle: Allows reading files in streaming chunks without loading the full file into RAM.
  • arrayBuffer(): Returns a Promise resolving to the chunk's raw binary content, ready for encryption and transmission.
  • Write Interface: Received chunks can be streamed directly to disk using FileSystemWritableFileStream.
  • Memory Efficient: Both sender and receiver only need to hold one chunk window in memory at a time.

3. Chunking Strategy and Flow Control

An RTCDataChannel has an internal send buffer. If the application sends data faster than the SCTP transport can flush it, the buffer fills up. Attempting to call dc.send() when the buffer is full throws a NetworkError. Proper flow control is therefore essential for reliable large-file transfers. The bufferedAmount property of an RTCDataChannel reports how many bytes are currently queued in the send buffer. The application should pause sending new chunks whenever bufferedAmount exceeds a threshold (typically 512 KB to 2 MB) and resume only when the bufferedamountlow event fires, indicating the buffer has drained below the low-water mark. Share2Me implements an async chunk queue that honours this backpressure mechanism, ensuring large files transfer reliably across slow or congested network connections without buffer overflow errors.

  • CHUNK_SIZE: Typically 128 KB per chunk — small enough to stay well within the 16 MB DataChannel message limit.
  • bufferedAmount: Monitor this property to detect when the send buffer is filling up.
  • bufferedamountlow event: Resume sending chunks when this event fires — signals the buffer has drained.
  • NACK Retry: Share2Me implements application-level chunk retry for chunks that fail to arrive at the receiver.

4. Practical Performance: What to Expect

In real-world testing, WebRTC DataChannel transfers achieve the following speeds: on the same local gigabit network, throughput of 300-800 Mbps is achievable (limited by browser encryption overhead). Across a 100 Mbps symmetric fiber internet connection, expect 60-80 Mbps effective throughput. Across a typical 50 Mbps down / 20 Mbps up residential connection, the transfer is limited by the sender's 20 Mbps upload speed, yielding approximately 2.5 MB/s. These speeds include AES-GCM-256 encryption overhead in the browser — in tests on a 2022 M2 MacBook Air, encryption overhead was less than 3% of total transfer time, consistent with the hardware AES-NI acceleration available on that chip.

  • Local Gigabit: 300-800 Mbps effective throughput (encryption overhead ~2-3%).
  • 100 Mbps Fiber: 60-80 Mbps effective — approaching wire speed after DTLS handshake overhead.
  • 50/20 Mbps Home: ~20 Mbps effective — limited by sender's upload bandwidth.
  • Mobile LTE: 15-30 Mbps effective on a strong LTE connection — comparable to desktop speeds on cellular.

Conclusion

The browser has evolved into a complete network transport platform. WebRTC, the File System Access API, and the Web Crypto API combine to provide everything needed for high-performance, privacy-preserving, browser-native file transfer without any cloud backend. Developers building tools that involve large file transfers should strongly consider WebRTC as an alternative to traditional upload-download architectures, particularly for use cases where privacy, file size limits, or real-time streaming are important requirements.

K

Written by Kamal Tripathi

Founder & Lead Engineer, Share2Me

Kamal is the founder of Share2Me and a full-stack engineer specialising in real-time browser communications, WebRTC, and cryptographic systems. He built Share2Me to solve the problem of cross-platform, privacy-first file sharing without requiring app installations.

Last updated: August 10, 2026