Open-source project
webtorrent/webtorrent avatar
webtorrent/webtorrent

WebTorrent: Streaming Torrents in the Browser Without Plugins

⚡️ Streaming torrent client for the web

31,410 stars2,900 forksJavaScriptMIT

At a glance

What is it?
WebTorrent brings BitTorrent to the browser by replacing TCP and UDP with WebRTC data channels, so any webpage can download and stream torrent files without plugins. It runs the same JavaScript code in Node.js and the browser, with one firm constraint: browser peers can only connect to other WebTorrent-compatible clients.
Who is it for?
WebTorrent is the right choice when you need torrent-based file distribution that runs inside a web page without asking users to install anything. It is the wrong choice when maximum peer reach matters, because browser clients cannot connect to standard TCP/UDP BitTorrent peers.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 10 days ago.
What is it written in?
Mainly JavaScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 22, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

BitTorrent Without Browser Plugins

The traditional BitTorrent protocol moves data over TCP and UDP connections, which browsers do not expose to JavaScript. WebTorrent solves this by substituting WebRTC data channels for transport. WebRTC is built into every modern browser, requires no extensions, and works without changing browser settings. The result is a BitTorrent client that loads from a script tag or an npm import and works in Chrome, Firefox, Opera, and Safari.

The same npm package handles both environments. In Node.js it uses TCP and UDP to reach the wider BitTorrent network. In the browser it falls back to WebRTC only. A developer can write a single JavaScript codebase that deploys on both a server and a web page, with the package adapting its transport layer automatically.

How WebRTC Replaces the BitTorrent Transport

When a browser WebTorrent client starts, it connects to a WebTorrent tracker rather than a standard UDP tracker. The tracker brokers the WebRTC signalling needed to establish a data channel between two browser tabs. Once connected, peers exchange BitTorrent protocol messages over that data channel.

To retrieve torrent metadata from a magnet link, WebTorrent uses the ut_metadata extension. For peer discovery it supports DHT, tracker, LSD (local service discovery), and ut_pex. Piece selection switches between sequential order for streaming and rarest-first for swarm health depending on how the file is being consumed.

File contents are exposed as Node.js-style streams. The library fetches only the pieces needed immediately, which means a video file can start playing before the download completes. The README documents that files can be piped into a `<video>` or `<audio>` tag directly. Supported container formats include WebM, MKV, MP4, MOV, and OGV with codecs including AV1, H264, HEVC, VP8, VP9, AAC, FLAC, MP3, OPUS, and Vorbis.

Installing WebTorrent and Downloading a First File

To add WebTorrent as a library in a Node.js project or a browser bundle built with webpack or Browserify, install it from npm:

bash
npm install webtorrent

For command-line use, install the companion CLI globally:

bash
npm install webtorrent-cli -g

The README gives this as the canonical browser download example:

js
import WebTorrent from 'webtorrent'

const client = new WebTorrent()
const magnetURI = '...'

client.add(magnetURI, torrent => {
  console.log('Client is downloading:', torrent.infoHash)

  for (const file of torrent.files) {
    document.body.append(file.name)
  }
})

The `client.add()` call accepts a magnet URI, a `.torrent` file URL, or a parsed torrent object. The callback fires once torrent metadata is available. Seeding from a browser drop target follows the same pattern using `client.seed(files, callback)`.

A pre-built browser bundle is available from the jsDelivr CDN as `webtorrent.min.js`. Projects that skip a bundler can include that script tag directly, which adds `window.WebTorrent` to the page. The README also documents Webpack configuration and Browserify use for projects that bundle their own assets.

The WebRTC Peer Compatibility Constraint

The largest practical constraint is that browser peers can only connect to other WebRTC-capable clients. A standard BitTorrent client running qBittorrent or Transmission cannot seed to a WebTorrent browser client. This is not a bug: it follows from browsers lacking TCP and UDP socket APIs.

The practical consequence is that seeding content to web users requires either WebTorrent Desktop, the webtorrent-hybrid command-line tool, or Instant.io. The README notes that Vuze has added WebTorrent support, enabling it to connect to both standard and web peers. Without a bridge peer in the swarm, browser clients will find nothing to download from.

A second constraint appears in the browser build. The `browser` field in `package.json` maps several Node modules to false: `bittorrent-dht`, `ut_pex`, `net`, `fs`, `os`, and `crypto` are all disabled in the browser bundle. Projects using the pre-built `webtorrent.min.js` lose Node-side DHT and PEX as a result.

Companion Tools: Desktop App, CLI, and Hybrid

WebTorrent Desktop is a separate installable application for macOS, Windows, and Linux. It connects to both the standard BitTorrent network over TCP/UDP and to browser peers over WebRTC. It is the most common way to seed content to web peers without writing code, and the README links to it as the primary reference for end users.

The webtorrent-cli package provides a Node.js command-line interface. The webtorrent-hybrid package bridges both transports in a single Node.js process, suited for server-side seeding where a desktop GUI is not practical.

Instant.io is a web application that lets anyone share files through a browser tab with no software installation. It uses WebTorrent internally and can serve as a quick test of whether a particular magnet link resolves in a browser environment.

WebTorrent Versus libtorrent-Based Clients

Traditional clients such as qBittorrent and Transmission are built on libtorrent, a C++ library that uses TCP and UDP. They can reach the full BitTorrent network and support a broader set of BitTorrent extension protocols. They do not support WebRTC and cannot connect to browser WebTorrent peers without a bridge.

WebTorrent trades universal peer compatibility for the ability to run inside a webpage. For a developer building a download interface that operates in the browser with no extensions, WebTorrent is the only option built on open web standards. For a server-side downloader where maximum peer availability matters, a libtorrent-based tool will reach more seeds and support more BEPs.

WebTorrent publishes a list of which BitTorrent Enhancement Proposals it supports at `docs/bep_support.md`. Checking that file against the BEPs your use case requires is the concrete verification step before committing to the library.

Editorial conclusion

WebTorrent is the right choice when you need torrent-based file distribution that runs inside a web page without asking users to install anything. It is the wrong choice when maximum peer reach matters, because browser clients cannot connect to standard TCP/UDP BitTorrent peers. Before adopting it, confirm that your seeding infrastructure includes a WebTorrent-compatible peer such as WebTorrent Desktop or webtorrent-hybrid, otherwise browser clients will find no seed to connect to. The project is MIT licensed, distributed as an ES module, and was at version 3.0.21 as of July 2026.

Frequently asked questions

What does WebTorrent do?

WebTorrent is a streaming BitTorrent client that runs in the browser using WebRTC data channels for peer-to-peer transport, requiring no plugins or extensions. In Node.js it uses TCP and UDP, while in the browser it substitutes WebRTC so the same JavaScript code works in both environments. Files are exposed as streams, allowing video playback to start before a download finishes.

How to use WebTorrent?

Install the npm package with `npm install webtorrent`, create a WebTorrent client instance, and call `client.add(magnetURI, callback)` to start downloading. The README also provides a `client.seed(files, callback)` example for sharing files from a browser drag-and-drop target.

How to install WebTorrent?

Run `npm install webtorrent` to add the library to a Node.js or browser project, or `npm install webtorrent-cli -g` for the command-line interface. For a desktop application on macOS, Windows, or Linux, download WebTorrent Desktop from its separate repository.

What is WebTorrent Desktop?

WebTorrent Desktop is a separate installable application for macOS, Windows, and Linux that bridges both the standard BitTorrent network over TCP/UDP and the WebRTC-based WebTorrent network. Because standard torrent clients cannot connect to browser peers, WebTorrent Desktop acts as the link between the two peer ecosystems.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. webtorrent/webtorrent on GitHub
For maintainers

Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/webtorrent-webtorrent.svg)](https://hysenlabs.com/projects/webtorrent-webtorrent)
Community notes

Community notes