webtorrent is a free, open source browsers & extensions project written in JavaScript and released under MIT. It has 31,397 GitHub stars, 2,902 forks and 83 open issues, and was last pushed 2 days ago. On this registry it ranks #11 of 65 tracked projects in Browsers & Extensions, with 5 head-to-head comparisons available. It gained 3 stars over the last 3 tracked days.

What is webtorrent?

What it is

WebTorrent is a streaming torrent client written entirely in JavaScript, distributed as a single npm package that runs both in node.js and in the browser. In node.js it behaves as an ordinary torrent client, using TCP and UDP to communicate with other clients. In the browser it uses WebRTC data channels for peer-to-peer transport, which means it works without browser plugins, extensions, or installations. The project lives in the JavaScript and node.js ecosystem, is licensed under MIT, and has been developed for roughly thirteen years.

The concrete problem it solves is that BitTorrent has historically been unavailable to web pages, because browsers cannot open raw TCP or UDP sockets. WebTorrent closes that gap by adapting the BitTorrent protocol to run over WebRTC, the only peer-to-peer transport available on the web. This required protocol changes, so a browser-based client, called a web peer, can only connect to other clients that support WebTorrent and WebRTC. Files are exposed as streams and pieces are fetched from the network on demand, so playback or seeking can begin before a torrent has finished downloading.

Key capabilities

  • Runs the same npm package in node.js and the browser, with TCP and UDP transport in node and WebRTC data channels in the browser.
  • Exposes torrent files as streams and fetches pieces on demand, so seeking works even before the torrent is complete.
  • Switches between sequential and rarest-first piece selection strategies.
  • Supports magnet URIs through ut_metadata, and peer discovery through DHT, tracker, LSD, and ut_pex.
  • Downloads multiple torrents simultaneously.
  • Provides a protocol extension API for adding new BitTorrent extensions, with supported BEPs documented in the repository.
  • Streams video torrents into a video tag across webm, mkv, mp4, ogv, and mov containers, and supports Chrome, Firefox, Opera, and Safari.

Who uses it and how

  • WebTorrent Desktop, a desktop client with a familiar interface that can connect to web peers and seed files to them.
  • webtorrent-hybrid, a command line program used to seed files to web peers.
  • Instant.io, a website that serves as a browser-based WebTorrent client.
  • Vuze, an established torrent client that added WebTorrent support so it can connect to both normal and web peers.
  • Web pages that include the webtorrent.min.js script or import the module through browserify or webpack to fetch files over WebRTC.

Getting started

Install for node or browser use with npm install webtorrent, or install the command line program with npm install webtorrent-cli -g. A prebuilt webtorrent.min.js is available from jsDelivr for direct script inclusion, and a desktop application is offered for Mac, Windows, and Linux.

When to use it — and when not to

WebTorrent is the practical choice

project readme (upstream, from github) — read inline


WebTorrent
WebTorrent

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

discord ci npm version npm downloads Standard - JavaScript Style Guide

Sponsored by    Socket - JavaScript open source supply chain security    Wormhole

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 import WebTorrent from 'webtorrent' with browserify or webpack. 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][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.

Network

Features

  • 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)
  • Check all the supported BEPs here
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 `` tag (webm, mkv, mp4, ogv, mov, etc (AV1, H264, HEVC*, VP8, VP9, AAC, FLAC, MP3, OPUS, Vorbis, etc))
  • Supports Chrome, Firefox, Opera and Safari.

Install

To install WebTorrent for use in node or the browser with import WebTorrent from '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][webtorrent-desktop].

Ways to help

Who is using WebTorrent today?

Lots of folks!

WebTorrent API Documentation

Read the full API Documentation.

Usage

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:
import WebTorrent from 'webtorrent'

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

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

  for (const file of torrent.files) {
    document.body.append(file.name)
  }
})
Seeding a file is simple, too:
import dragDrop from 'drag-drop'
import WebTorrent from 'webtorrent'

const client = new WebTorrent()

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

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

Browserify

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

Webpack

WebTorrent also works with webpack, another module bundler. However, webpack requires extra configuration which you can find in the webpack bundle config used by webtorrent.

Or, you can just use the pre-built version via import WebTorrent from 'webtorrent/dist/webtorrent.min.js' and skip the webpack configuration.

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 type='module'>
  import WebTorrent from 'webtorrent.min.js'
</script>

The WebTorrent script is also hosted on fast, reliable CDN infrastructure for easy inclusion on your site:

<script type='module'>
  import WebTorrent from 'https://esm.sh/webtorrent/dist/webtorrent.min.js'
</script>
Chrome App

If you want to use WebTorrent in a Chrome App, you can include the following script:

<script type='module'>
  import WebTorrent from 'webtorrent.chromeapp.js'
</script>

Be sure to enable the chrome.sockets.udp and chrome.sockets.tcp permissions!

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 [web

readme truncated — read the full docs on github

Frequently asked questions

Is webtorrent free to use?

webtorrent is open source under the MIT licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does webtorrent do?

⚡️ Streaming torrent client for the web

What is webtorrent written in?

webtorrent is primarily written in JavaScript. Its source is publicly available at https://github.com/webtorrent/webtorrent, and it has 31,397 GitHub stars.