⚡️ Streaming torrent client for the web


License: MIT

Language: JavaScript

Keywords: bittorrent, browser, javascript, nodejs, p2p, streaming, torrent, webrtc, webtorrent


The streaming torrent client. For node.js and the web.

gitter travis appveyor npm version npm downloads Standard - JavaScript Style Guide

WebTorrent is a streaming torrent client for node.js and the browser. YEP, THAT'S RIGHT. THE BROWSER. It's written completely in JavaScript – the language of the web – so the same code works in both runtimes.

In node.js, this module is a simple torrent client, using TCP and UDP to talk to other torrent clients.

In the browser, WebTorrent uses WebRTC (data channels) for peer-to-peer transport. It can be used without browser plugins, extensions, or installations. It's Just JavaScript™. Note: WebTorrent does not support UDP/TCP peers in browser.

Simply include the webtorrent.min.js script on your page to start fetching files over WebRTC using the BitTorrent protocol, or require('webtorrent') with browserify. See demo apps and code examples below.

jsdelivr download count

To make BitTorrent work over WebRTC (which is the only P2P transport that works on the web) we made some protocol changes. Therefore, a browser-based WebTorrent client or "web peer" can only connect to other clients that support WebTorrent/WebRTC.

To seed files to web peers, use a client that supports WebTorrent, e.g. WebTorrent Desktop, a desktop client with a familiar UI that can connect to web peers, webtorrent-hybrid, a command line program, or Instant.io, a website. Established torrent clients like Vuze have already added WebTorrent support so they can connect to both normal and web peers. We hope other clients will follow.


Open Source Sponsors


  • Torrent client for node.js & the browser (same npm package!)
  • Insanely fast
  • Download multiple torrents simultaneously, efficiently
  • Pure Javascript (no native dependencies)
  • Exposes files as streams
    • Fetches pieces from the network on-demand so seeking is supported (even before torrent is finished)
    • Seamlessly switches between sequential and rarest-first piece selection strategy
  • Supports advanced torrent client features
  • Comprehensive test suite (runs completely offline, so it's reliable and fast)

Browser/WebRTC environment features

  • WebRTC data channels for lightweight peer-to-peer communication with no plugins
  • No silos. WebTorrent is a P2P network for the entire web. WebTorrent clients running on one domain can connect to clients on any other domain.
  • Stream video torrents into a <video> tag (webm (vp8, vp9) or mp4 (h.264))
  • Supports Chrome, Firefox, Opera and Safari.

Sauce Labs


To install WebTorrent for use in node or the browser with require('webtorrent'), run:

npm install webtorrent

To install a webtorrent command line program, run:

npm install webtorrent-cli -g

To install a WebTorrent desktop application for Mac, Windows, or Linux, see WebTorrent Desktop.

Ways to help

Who is using WebTorrent today?

Lots of folks!

WebTorrent API Documentation

Read the full API Documentation.


WebTorrent is the first BitTorrent client that works in the browser, using open web standards (no plugins, just HTML5 and WebRTC)! It's easy to get started!

In the browser

Downloading a file is simple:
var WebTorrent = require('webtorrent')

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

client.add(magnetURI, function (torrent) {
  // Got torrent metadata!
  console.log('Client is downloading:', torrent.infoHash)

  torrent.files.forEach(function (file) {
    // Display the file by appending it to the DOM. Supports video, audio, images, and
    // more. Specify a container element (CSS selector or reference to DOM node).
Seeding a file is simple, too:
var dragDrop = require('drag-drop')
var WebTorrent = require('webtorrent')

var client = new WebTorrent()

// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', function (files) {
  client.seed(files, function (torrent) {
    console.log('Client is seeding:', torrent.infoHash)

There are more examples in docs/get-started.md.


WebTorrent works great with browserify, an npm package that let's you use node-style require() to organize your browser code and load modules installed by npm (as seen in the previous examples).


WebTorrent also works with webpack, a module bundler similar to browserify. However, webpack requires the following extra configuration:

  target: 'web',
  node: {
    fs: 'empty'

If you are on webpack 1.x, you will also need to add the json-loader:

  module: {
    loaders: [
      // make sure to install the 'json-loader' package: npm install json-loader
        test: /\.json$/,
        loader: 'json'

Otherwise you could also directly use the pre-built version via require('webtorrent/webtorrent.min').

Script tag

WebTorrent is also available as a standalone script (webtorrent.min.js) which exposes WebTorrent on the window object, so it can be used with just a script tag:

<script src="webtorrent.min.js"></script>

The WebTorrent script is also hosted on fast, reliable CDN infrastructure (Cloudflare and MaxCDN) for easy inclusion on your site:

<script src="https://cdn.jsdelivr.net/npm/webtorrent@latest/webtorrent.min.js"></script>

In Node.js

WebTorrent also works in node.js, using the same npm package! It's mad science!

NOTE: To connect to "web peers" (browsers) in addition to normal BitTorrent peers, use webtorrent-hybrid which includes WebRTC support for node.

As a command line app

WebTorrent is also available as a command line app. Here's how to use it:

$ npm install webtorrent-cli -g
$ webtorrent --help

To download a torrent:

$ webtorrent magnet_uri

To stream a torrent to a device like AirPlay or Chromecast, just pass a flag:

$ webtorrent magnet_uri --airplay

There are many supported streaming options:

--airplay               Apple TV
--chromecast            Chromecast
--mplayer               MPlayer
--mpv                   MPV
--omx [jack]            omx [default: hdmi]
--vlc                   VLC
--xbmc                  XBMC
--stdout                standard out [implies --quiet]

In addition to magnet uris, WebTorrent supports many ways to specify a torrent.

Talks about WebTorrent


Most of the active development is happening inside of small npm packages which are used by WebTorrent.

The Node Way™

"When applications are done well, they are just the really application-specific, brackish residue that can't be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons." — substack from "how I write modules"

node.js is shiny


These are the main modules that make up WebTorrent:

module tests version description
webtorrent torrent client (this module)
bittorrent-dht distributed hash table client
bittorrent-peerid identify client name/version
bittorrent-protocol bittorrent protocol stream
bittorrent-tracker bittorrent tracker server/client
create-torrent create .torrent files
magnet-uri parse magnet uris
parse-torrent parse torrent identifiers
render-media intelligently render media files
torrent-discovery find peers via dht and tracker
ut_metadata metadata for magnet uris (protocol extension)
ut_pex peer discovery (protocol extension)

Enable debug logs

In node, enable debug logs by setting the DEBUG environment variable to the name of the module you want to debug (e.g. bittorrent-protocol, or * to print all logs).

DEBUG=* webtorrent

In the browser, enable debug logs by running this in the developer console:

localStorage.debug = '*'

Disable by running this:



MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.

Project Statistics

Sourcerank 17
Repository Size 6.54 MB
Stars 18,236
Forks 1,752
Watchers 711
Open issues 93
Dependencies 54
Contributors 130
Tags 277
Last updated
Last pushed

Top Contributors See all

Feross Aboukhadijeh Diego Rodríguez Baquero greenkeeper[bot] Joseph Frazier Travis Fischer Greenkeeper Jimmy Wärting Astro DC Kaylee https://github.com/josephfrazier Valérian Galliat grunjol John Hiesey Gilles De Mey Andrea Paiola Alberto Miranda Joseph Dykstra Lunik Simba Zhang

Packages Referencing this Repo

⚡️ Streaming torrent client for the web
Latest release v0.103.0 - Published - 18.2K stars
Streaming torrent client
Latest release 0.103.0 - Updated - 18.2K stars

Recent Tags See all

v0.103.0 December 11, 2018
v0.102.4 August 30, 2018
v0.102.3 August 30, 2018
v0.102.2 August 27, 2018
v0.102.1 August 10, 2018
v0.102.0 August 04, 2018
v0.101.2 July 27, 2018
v0.101.1 July 27, 2018
v0.101.0 July 18, 2018
v0.100.0 May 23, 2018
v0.99.4 May 04, 2018
v0.99.3 April 27, 2018
v0.99.2 April 25, 2018
v0.99.1 April 25, 2018
v0.99.0 April 19, 2018

Interesting Forks See all

Streaming torrent client for node & the browser
JavaScript - MIT - Updated - 1 stars - 1 forks
⚡️ Streaming torrent client for the web
JavaScript - Last pushed - 1 stars
⚡️ Streaming torrent client for the web
JavaScript - Updated - 1 stars
⚡️ Streaming torrent client for the web
JavaScript - Updated - 1 stars
Streaming torrent client for node and the browser
JavaScript - MIT - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2018-12-11 00:36:41 UTC

Login to resync this repository