31.5K ·GitHub
What is this?
A streaming torrent client written entirely in JavaScript that runs in node.js and the browser — in the browser it moves data over WebRTC data channels, with no plugins, extensions, or installs.
Is this an app I install, or a library I code against?
It's a library: the same npm package works in node.js and the browser. The command-line app and the WebTorrent Desktop app are separate projects.
How do I add it to a project?
Run npm install webtorrent, then import WebTorrent from 'webtorrent' with browserify or webpack — or skip bundling and include the prebuilt webtorrent.min.js with a script tag or CDN.
What do I need installed before it will run?
In the browser, just a WebRTC-capable browser — the code is pure JavaScript with no native dependencies. In node.js it needs Node.js 22 or newer.
Can it download from the normal BitTorrent swarm?
Not from a browser: web peers speak WebRTC only and cannot reach regular TCP/UDP peers. To bridge both worlds, seed with webtorrent-hybrid, WebTorrent Desktop, or Instant.io.
Which browsers can run it?
Chrome, Firefox, Opera and Safari. The same package also runs server-side in node.js.
Can I use it in my own project, even commercially?
Yes — WebTorrent is MIT licensed, so it's free to use, modify, and ship in commercial products as long as you keep the copyright notice.
What does streaming mean here — can I watch a video before the download finishes?
Yes. Pieces are fetched from the network on demand, so seeking works even before the torrent finishes, and video (webm, mkv, mp4, and more) can be streamed straight into a page element. The CLI can also stream to AirPlay or Chromecast with a flag.
Does it handle magnet links and trackerless swarms?
Yes. Magnet URIs work via the ut_metadata extension, and peers are discovered through DHT, trackers, local service discovery (LSD), and ut_pex. Beyond magnet links, many other ways to specify a torrent are supported.
Why run BitTorrent in the browser at all?
It's the first BitTorrent client built on open web standards — no plugins, just HTML5 and WebRTC. The idea is a P2P network with no silos: clients on one domain can connect to clients on any other domain, and established clients like Vuze already support it.
Is it one big codebase or a set of small modules?
A set of small modules. Most active development happens in separate npm packages — bittorrent-dht, bittorrent-protocol, bittorrent-tracker, create-torrent, parse-torrent, magnet-uri — which WebTorrent stitches together.
What are similar projects?
webtorrent-desktop, trystero, trackerslist, steam2_downloader, yjs, gopeed, pooled, qBittorrent
Which topics is it in?
webtorrent, bittorrent, peer-to-peer, torrent, file-sharing, video-streaming, webrtc, p2p, downloader, javascript-library, streaming, browser