Bring WebRTC P2P File Sharing to Your Website with FFL.js
Posted on Fri 04 December 2026 in Blog
Imagine an online video editor: someone finishes editing in their browser, clicks Share, and sends the resulting link to a client. A multi-gigabyte video can travel directly from the sender's browser to the recipient, without first uploading it to the editor's cloud storage.
The same capability fits reporting tools, photo applications, collaboration software, and AI applications that generate data in the browser. FFL.js lets JavaScript developers add this workflow to their products: turn a file, folder, or stream their application can read into a shareable HTTPS link and deliver the data peer to peer.
To try it, open the FFL.js Playground, select a file, folder, or stream source, and create a link for another device to download. The page also includes integration examples.
From a share link to peer-to-peer delivery
FastFileLink (FFL) is a file and data sharing tool that creates share links, manages transfers, and provides features such as encryption and access control. FFL.js is its JavaScript SDK: a development library that brings FFL capabilities to browser and Node.js applications.
When someone shares, the application gives FFL.js a data source. The SDK starts a sharing session and returns an HTTPS link. The recipient opens the link to access the download page; compatible FFL clients can receive the share too.
In the browser, FFL.js uses WebRTC, a browser technology for real-time communication. When the peers establish a direct P2P (peer-to-peer) connection, file data travels directly from sender to recipient, saving server storage and transfer bandwidth. Network services still provide the download page and coordinate the connection. When a direct connection is unavailable, WebRTC TURN relay or HTTP relay can carry the transfer. The actual path depends on connectivity and share settings.
What can you share?
FFL.js can share data your application can already read:
- Files and folders: selected media, project directories, or diagnostic data.
- Text and binary data: reports, images, and other content generated by a page.
- Streams: data supplied through a
ReadableStreamas it is produced or read, such as media obtained by the application.
In the browser, the application obtains the user's chosen files or folders and accesses them within the browser's permissions. It can also share data in OPFS, the website's Origin Private File System, using the corresponding file handles. FFL reads large local files on demand through read-only mounts.
A video editor can deliver its output; a photo organizer can share a selected folder; and a browser-based AI application can share a generated report or dataset. For remote sources, the source server must allow the website to read the data through CORS (Cross-Origin Resource Sharing) before the application can pass it to FFL.js.
Add sharing to a web application
Install the package:
This example accepts a File obtained from a file picker or drag-and-drop operation, then creates a share with end-to-end encryption (E2EE). E2EE encrypts the data at the sender and decrypts it at the recipient.
Display session.link in your interface so the user can copy it. This example allows one download and sets a 30-minute lifetime. Applications can also listen for transfer progress and completion events. Keep the page and session open while sharing: the sender supplies the data, and mobile browsers may suspend background pages or locked screens.
For folders, streams, transfer events, download-page branding, and advanced networking, see the browser integration guide and SDK documentation.
How it works
FFL.js provides the JavaScript interface; FFL Core manages sharing, connection negotiation, and encryption. Together with browser WebRTC, they bring the same FFL sharing engine into a website.
In the browser, unkernel provides a Linux environment through WebAssembly, a program format browsers can run. It runs ffl.com, FFL's portable executable. The FFL.js browser bridge delegates WebRTC operations to the browser, while FFL Core continues to manage sharing and transfer logic.
The SDK automatically selects a pair of network services to provide the download page and coordinate connections. Bore creates a public tunnel, and Wisp provides outbound connectivity for the Linux environment in the browser. With a direct WebRTC connection, file data travels directly between the peers. Applications that need custom nodes can use the network configuration in the integration guide.
Preparing for deployment
Recent versions of most mainstream browsers support the technology needed to run FFL.js. Use an up-to-date browser and test the sharing flow on your target devices.
For integration, the browser SDK requires HTTPS (localhost is suitable for development), WebAssembly JSPI, and cross-origin isolation. JSPI lets WebAssembly wait for asynchronous JavaScript operations; cross-origin isolation requires the appropriate HTTP response headers. Chrome and Edge 137 or later are the starting points listed in the project documentation.
Host the SDK's runtime assets and preserve their relative paths when bundling. Preparing the runtime for the first time involves loading these assets, so an application can start preparing while the user selects a file. For current headers, assets, and browser requirements, consult the deployment guide.
Use it with Node.js
FFL.js also provides a Node.js interface for server applications, command-line tools, and automation. It can share local files, folders, and streams, and provides download and event APIs. Node.js runs the native FFL executable; compatible FFL peers can use TCP/QUIC P2P, and WebRTC is also supported. Installation and examples are in the project README.